HTTP server detecting a broken network connection from a HTTP client

前端 未结 2 467
忘掉有多难
忘掉有多难 2021-01-24 05:21

I have an web application in which after making a HTTP request to the server, the client quits ( or network connection is broken) before the response was completely received by

相关标签:
2条回答
  • 2021-01-24 06:10

    No, there is nothing built in to the protocol to do this (after all, you can't tell whether the response has been received by the client itself yet, or just a downstream proxy).

    Just have your client make a second request to acknowledge that it has received and stored the original response. If you don't see a timely acknowedgement, run the cleanup.

    However, make sure that you understand the implications of the Two Generals' Problem.

    0 讨论(0)
  • 2021-01-24 06:21

    You might have a network problem... usualy, when you send a HTTP request to the server, first you send headers and then the content of the POST (if it is a post method). Likewise, the server responds with the headers and document body. The first line in the header is the status. Usually, status 200 is the success status, if you get that, then there should be no problem getting the rest of the document. Check this for details on the HTTP response status headers http://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html

    LE: Sorry, missread your question. Basically, you don't have a trigger for when the user disconnects. If you use OOP, you could use the destructor of a class to clean whatever it is you need to clean.

    0 讨论(0)
提交回复
热议问题