Http请求响应调试

发布于 2024-08-17 07:16:09 字数 298 浏览 7 评论 0原文

我有两部手机连接到 Wifi 接入点,它们的 IP 都在专用范围内。 其中一部手机上运行着 HTTP 服务器,另一部手机则充当客户端。客户端以 name/ 的形式向服务器发送 GET 请求数据 URL 查询字符串中的值对。目前,服务器仅在收到查询字符串时通过 HTTP.OK 发送。

发生的情况是客户端可能不是静止的,可能会四处移动,因此它可能无法始终处于 Wifi 访问范围内 由于我没有在服务器端获取从客户端发送的所有数据。 我想确保所有发送的数据都被服务器实际接收到。

我应该实施什么样的错误纠正?我可以检查一些相关的 HTTP 错误代码等吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

手长情犹 2024-08-24 07:16:09

如果 HTTP 服务器没有收到 GET 请求中的整个查询字符串,则 HTTP 请求不可能有效,因为这些参数位于请求的第一行。

服务器将无法处理该请求,在这种情况下可能会返回状态代码 400(错误请求)。

如果您的客户端收到此消息(这似乎不太可能无法传输请求,但会收到响应),那么您就会知道要重新传输。一般来说,TCP 连接的属性(例如自动重传、校验和和超时)应该是成功交付或确定失败所需的全部。

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.

用心笑 2024-08-24 07:16:09

您需要检查客户端上的超时情况。这取决于所使用的流程/语言。

编辑: http://wiki.forum.nokia.com/index.php/Using_Http_and_Https_in_Java_ME< /a>

看起来您只是设置了超时并捕获 IO 错误。

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.

山田美奈子 2024-08-24 07:16:09

过早的优化。

连接完整性已在网络堆栈的较低部分处理。因此,如果请求中间出现任何丢失(假设它跨越多个数据包),TCP 堆栈将在将数据传递到服务器之前尝试恢复它们。

如果您需要向自己证明这一点,只需添加校验和作为查询的最后部分即可。

C.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文