How does the browser cancel the http request (canceled), server to judge?

the server is koa2,. How do I get the operation that the client canceled the request?

clipboard.png


http request is a typical request / response model.

if you send it, you send it, and if you accept it, you accept it. If I send a request to the backend, the backend accepts a cancellation request. How to write the background logic? It's gonna be a mess.

if you have to listen to this situation, you can listen in req.close

therefore, there is no such thing as a back-end cancellation. The so-called cancellation means that the front end unilaterally does not handle the response of the request, in other words, the callback function of the
logout request. Generally speaking, the back-end will not handle the cancellation `

.

can be regarded as a unilateral breach by the browser. The request is either not sent or rejected by the browser, but neither is perceived by the server.

besides, I don't know what scene caused the problem?


the problem has been resolved.

if the connection is broken, the server side can also judge.
for more information, please refer to here

this is what I wrote:

  ctx.req.on('close', () => {
    // ...
  })
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37b6c-2c0cc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37b6c-2c0cc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?