使用套接字获取内容长度

发布于 2024-10-06 12:57:17 字数 70 浏览 0 评论 0原文

谁能指导我仅使用套接字获取网站的 POST 内容长度。谢谢和荣誉! (由于某种原因我避免使用 httpwebrequest )

Can anyone guide me in acquiring the POST content-length of a website by just using sockets. Thanks and Kudos!
(I'm avoiding using httpwebrequest for some reason)

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

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

发布评论

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

评论(3

爱你不解释 2024-10-13 12:57:17

如果它是代理应用程序,则根本不需要解析标头。您只需将数据以字节形式从一侧镜像到另一侧。您需要解析的唯一内容是例如初始 HTTP CONNECTION 请求,或者与客户端的初始握手导致您建立上游连接的任何内容。剩下的只是字节复制、EOS 和错误传播。

If it's a proxy application you don't need to be parsing headers at all. You just need to mirror the data from one side to the other, as bytes. The only thing you need to parse is for example the initial HTTP CONNECTION request, or whatever your initial handshake with the client is that causes you to set up the upstream connection. The rest of it is just byte copying and EOS and error propagation.

人海汹涌 2024-10-13 12:57:17

在 Http 协议中,标头与内容通过双 crlf 分隔开。

因此,您可以解析标头并获取 Content-Length 标头,也可以计算出内容的长度(因为您知道标头在哪里结束、内容在哪里开始)。

In the Http protocol the header is seperated from the content by a double crlf.

So you could either parse the header and get the Content-Length header or you can figure out the length of the content (since you know where the header ends and content starts).

墨小墨 2024-10-13 12:57:17

HTTP/1.1 消息长度规则在 RFC 2616 的 4.4 节

HTTP/1.1 message length rules are described in section 4.4 of the RFC 2616.

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