Search code examples
debugginghttpmobile-phones

Http request response debugging


I have two phones connected to a Wifi access point, both have ip in the private range. One of the phones has a HTTP server running on it and the other phone acts like a client. The client sends GET requests data to the server as name/ value pairs in the URL query string. At the moment the server is only sending on HTTP.OK on receiving the query string.

What is happening is the client may not be stationary and maybe moving around so it may not be possible for it to be in range always of the Wifi access point due to that I am not getting all the data sent from the client at the server end. I want to ensure that all data sent is actually received by the server.

What kind of error correction should I implement? Can I check for some relevant HTTP error codes or the like?


Solution

  • If the HTTP server doesn't receive the entire query string in a GET request, then the HTTP request cannot possibly be valid as these parameters are on the first line of the request.

    The server will be unable to handle the request and in this case will likely return status code 400 (Bad Request).

    If your client receives this (which seems unlikely that it would fail to transmit the request, yet receive the response), then you'll know to retransmit. In general, the properties of TCP connections like automatic retransmissions, checksums and timeouts should be all you need for successful delivery, or to determine failure.