C http请求gzip (zlib)
我正在使用winsock 发出http 请求,并且需要解析响应。问题是,无论我在请求标头中指定什么,某些网站都会进行 gzip 压缩。我什至尝试将请求降级为 HTTP/1.0
但没有成功。所以现在我要添加 deflate/gzip 支持,但没有运气。我让程序将压缩内容写入文件。然后我尝试使用 gzip 工具解压缩它,但它给出了一个错误,说它是一个多部分 gzip 文件。经过一番阅读后,我发现这是由于 gzip 标头由于未作为二进制文件处理而被损坏所致。我不知道此时该怎么办。
I'm making http requests using winsock and I need to parse the response. The problem is that some sites gzip no matter what I specify in my request header. I've even tried downgrading the request to HTTP/1.0
with no success. So now I'm to add deflate/gzip support and having no luck. I had my program write the compressed content to file. Then I tried decompressing it with the gzip
tool but it gave an error saying that it was a multi part gzip file. After some reading I found out that this is caused by the gzip header being corrupted due to not being handled as a binary. I'm not sure what to do at this point.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您将 gzip 压缩的数据写入文件时,您是否将其作为二进制文件打开?假设您像标题中那样使用 C,您是否使用 fopen(..., "wb") 打开?
When you write the gzipped data to a file, have you opened it as a binary file? Assuming you are using C as in the title, did you open with fopen(..., "wb")?