Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Correct HTTP Status Code for a Cancelled Request

When a TCP connection gets cancelled by the client while making a HTTP request, I'd like to stop doing any work on the server and return an empty response. What HTTP status code should such a response return?

like image 743
Muhammad Rehan Saeed Avatar asked Sep 15 '17 08:09

Muhammad Rehan Saeed


People also ask

What is a 309 status code?

Status codes 309 through 399 are currently unassigned.

Can http request be Cancelled?

We can use the AbortController object and the associated AbortSignal with the Fetch API to make cancelable HTTP requests. Once the AbortSignal is sent, the HTTP request is canceled and won't be sent if the cancellation signal is sent before the HTTP request is done.

What is a 299 status code?

HTTP response codes 200 – 299 are bearers of good news: the request has been accepted, a new request has been created, or a certain problem was solved.

What is 200 HTTP status code means?

The HTTP 200 OK success status response code indicates that the request has succeeded. A 200 response is cacheable by default. The meaning of a success depends on the HTTP request method: GET : The resource has been fetched and is transmitted in the message body.


1 Answers

To be consistent I would suggest 400 Bad Request now if your backend apps are capable of identifying when the client gets disconnected or if you reject or close the connection, probably you could return Nginx' non-standard code 499 or 444.

  • 499 Client Closed Request Used when the client has closed the request before the server could send a response.

  • 444 No Response Used to indicate that the server has returned no information to the client and closed the connection.

like image 146
nbari Avatar answered Sep 22 '22 20:09

nbari