How to verify that an HTTP response has been delivered?

To respond to the http request, we can simply use the returned "content" in the method function.

But for some critical use cases, I would like to make sure that the http OK response 200 OK was delivered. Any idea?

+4
source share
4 answers

The protocol HTTPdoes not work. If you need confirmation, you need the customer to send you a confirmation.

Or you should look at a bidirectional socket implementation ( socket.io sample library ), where the client can send an ACK. If this is critical, then do not let it be only on HTTP, usewebsockets

AJAX . UUID,

$ curl -v http://domain/url
....
response:

X-ACK-Token: 89080-3e432423-234234-23-42323

$ curl http://domain/ack/89080-3e432423-234234-23-42323

, , . ACK, , , ,

PS: UUID UUID, , ,

+9

.

, , , ( HTTP-, ).

Example

+1

tarun-lalwani - HTTP, . , , , 200 . , 200

0

HTTP, - Sockets, HTTP (, API), - .

, , , , - :

  • HTTP-, "ClientID" (, ) , .
  • 200 OK ( , )
  • 60 ( -).
    • , .
    • , , "ClientID" , 1.
      • The server detects that the "ClientID" has already been received.
        • Bring 409 Conflict back, saying that it "already exists" and the client needs to know how to handle it.
        • Or simply return 200 OK, and the client never knew that it was received for the first time.

Again, this is highly dependent on your business / technical requirements. Because you can even get two or more consecutive timeout processing cycles.

I hope you get an idea.

0
source

Source: https://habr.com/ru/post/1695228/


All Articles