开发者

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 开发者_如何学Cserver 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?


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.


You need to check for timeouts on the client. That depends on the process/language used.

EDIT: http://wiki.forum.nokia.com/index.php/Using_Http_and_Https_in_Java_ME

Looks like you simply set a timeout and catch IO errors.


Premature optimization.

Connection integrity is already dealt with in the lower parts of the network stack. So if there were any dropouts in the middle of the request (assuming it spanned more than a single packet) the TCP stack would attempt to recover them before passing the data on to the server.

If you need to prove this to yourself, then just add a checksum as the last part of the query.

C.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜