从 WinHttp 获取请求的实际总标头大小
标题几乎说明了一切;从 WinHttp 获取服务器响应中标头的大小很容易,但我需要知道请求的总大小,包括 HTTP 版本、动词、URL 以及 API 可能添加的任何随机内容。我知道单个请求的总大小有 8k 限制,但提供 8k 标头会导致错误。
我真的需要手动添加 HTTP 标准所需的所有内容才能获得总请求大小吗?看来应该有一个功能。
The title pretty much says it all; It's easy enough to get the size of the headers in the server's response from WinHttp, but I need to know the TOTAL size of my request, including the HTTP version, verb, URL, and any random stuff the API is probably adding. I know there's an 8k limit to the total size of a single request, but providing 8k of headers results in an error.
Do I really have to manually add up all the stuff required by the HTTP standard to get the total request size? Seems like there ought to be a function.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实际上,这取决于任务。例如,我需要统计我的流量。只有我能做的就是计算我的请求正文大小加上我的附加标头参数。我认为这都是为了 WinHttp 的传出流量。
Actually, it depends on the task. For example, I need to count my traffic. Only I could do it had been to calculate my request body size plus my additional header params. I think it's all for out-coming traffic with WinHttp.
WinHTTP API 为您创建请求行和标头,并提供提供自定义标头等的选项。如果您需要提供指示正文长度的标头,您也可以这样做,例如通过提供
Content-Length
标头以及您要发送的请求。您不需要计算总数,API 会为您完成此请求/响应管理。WinHTTP API creates request line and headers for you, with options to provide custom headers etc. If you need to provide a header which indicates body length, you can do it too, e.g. by providing
Content-Length
header with your request to be sent. You don't need to calculate the total, API does this request/response management for you.