Jelle De Loecker
Jelle De Loecker

Reputation: 21985

Receive 102 http status in XMLHttpRequest

Node.js supports sending a 102 Processing status code since v10, but I'm not sure how this can be used.

Is it something the browser only uses internally (like it delays the timeout event) or can we access this temporary status in any way?

I'd like to let my javascript code know "hey, I'm working on this, sit tight". Sending a temporary status seems like the easiest way out.

Another option is to work with a 202 status, but that requires a lot more changes.

Upvotes: 1

Views: 400

Answers (1)

acrazing
acrazing

Reputation: 2284

You are right.

102 PROCESSING

An interim response used to inform the client that the server has accepted the complete request, but has not yet completed it.

This status code SHOULD only be sent when the server has a reasonable expectation that the request will take significant time to complete. As guidance, if a method is taking longer than 20 seconds (a reasonable, but arbitrary value) to process the server SHOULD return a 102 (Processing) response. The server MUST send a final response after the request has been completed.

Methods can potentially take a long period of time to process, especially methods that support the Depth header. In such cases the client may time-out the connection while waiting for a response. To prevent this the server may return a 102 Processing status code to indicate to the client that the server is still processing the method.

You can see it at https://httpstatuses.com/102 or https://www.rfc-editor.org/rfc/rfc2518#section-10.1

Upvotes: 1

Related Questions