Can a http server detect that a client has cancelled their request?

While @Oded is correct that HTTP is stateless between requests, app servers can indeed detect when the underlying TCP/IP connection has broken for the request being processed. Why is this? Because TCP is a stateful protocol for reliable connections. A common technique for .Net web apps processing a resource intensive request is to check Response.IsClientConnected … Read more

Handling cancelled request with Express/Node.js and Angular

Injected reqobject is shipped with listeners .on(). Listening to close event allows to handle when client close the connection (request cancelled by Angular or, e.g., user closed the querying tab). Here are 2 simple examples how to use the closeevent to stop request processing. Example 1: Cancellable synchronous block var clientCancelledRequest=”clientCancelledRequest”; function cancellableAPIMethodA(req, res, next) … Read more

What is the Correct HTTP Status Code for a Cancelled Request

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 … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)