ICSharpCode.SharpZipLib.GZip.GZipInputStream与HTTP请求一起使用 [英] ICSharpCode.SharpZipLib.GZip.GZipInputStream Use with HTTP Request
问题描述
我正在使用.NET套接字类来编写Web客户端。当我来gzip编码的时候来了我的b $ b,我无法获得解码后的文本。
我找到了ICSharpCode.SharpZipLib来帮助,但是在使用它们的
示例代码,我一直遇到关于第一个字节的错误消息
不匹配。显然,它期望某个字节值为
的第一个字节,这使我认为我需要将编码的
主体从未编码的头部分开,然后发送只有GZIPInputStream的编码部分才能获得
。虽然我知道除法是由
空行确定的,但当我将它拆分为该行时(无论我是否在编码部分中包含
回车)我是仍然得到同样的错误。
有没有人能够使用该库来解码一个网页
有一个gzipped的身体?
谢谢!
< mw ***** @ gmail.com>写道:我使用.NET套接字类来编写Web客户端。当我来gzip编码时,我无法获得解码后的文本。
我发现ICSharpCode.SharpZipLib有帮助,但在使用他们的示例代码时,我一直遇到一个关于第一个字节的错误消息
不匹配。显然,它期望某个字节值作为第一个字节,这使我认为我需要将编码的物体从未编码的头部分开,并仅将编码的部分发送到
GZIPInputStream。虽然我知道除法是由空白行决定的,当我将它分割到该行时(无论我是否在编码部分中包含
回车),我仍然会得到同样的错误。有没有人能够使用该库来解码具有gzipped主体的网页?
我建议你将问题分成两半。你需要检查
:
1)你可以压缩一些然后解压缩它
2)你可以转移网络请求中没有丢失的二进制数据
我怀疑你的问题是在第二部分,但是你应该能够完全独立地工作第一部分。
-
Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet 博客: http://www.msmvps.com/jon.skeet
如果回复小组,请不要给我发邮件
我不确定你的帖子如何解决我的问题 - 你是否建议
我不喜欢为了使用
gzip库而且我的问题出在其他地方,我们需要将网页分成标题/正文吗?
>
< MW ***** @的Gmail。 COM>写道:我不确定你的帖子如何解决我的问题 - 你是否建议
我不需要将网页分成标题/正文以便使用
gzip库和我的问题在其他地方吗?
我建议你应该尽量确保你能成功
发送/接收任意二进制数据,以确定是否是'b
问题,或者是否是'gzipping'问题。
-
Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet 博客: http://www.msmvps.com/jon.skeet
如果回复小组,请不要给我发邮件
I am using the .NET socket class to program a web client. When I come
upon gzip encoded conent, I am having trouble getting the decoded text.
I have found the ICSharpCode.SharpZipLib to help, but in using their
sample code, I keep encountering an error message about the first byte
not matching. Clearly it is expecting a certain byte value as the
first byte, which leads me to think that I need to split the encoded
body away from the unencoded header, and send only the encoded part to
the GZIPInputStream. While I know that division is determined by a
blank line, when I split it over that line (whether I include the
carriage return in the encoded part or not) I still get the same error.
Has anyone been able to use that library for decoding a webpage that
has a gzipped body?
thanks!
<mw*****@gmail.com> wrote:I am using the .NET socket class to program a web client. When I come
upon gzip encoded conent, I am having trouble getting the decoded text.
I have found the ICSharpCode.SharpZipLib to help, but in using their
sample code, I keep encountering an error message about the first byte
not matching. Clearly it is expecting a certain byte value as the
first byte, which leads me to think that I need to split the encoded
body away from the unencoded header, and send only the encoded part to
the GZIPInputStream. While I know that division is determined by a
blank line, when I split it over that line (whether I include the
carriage return in the encoded part or not) I still get the same error.
Has anyone been able to use that library for decoding a webpage that
has a gzipped body?
I suggest you split the problem into two halves. You need to check
that:
1) You can zip something up and then unzip it
2) You can transfer binary data without loss in a web request
I suspect your problem is in the second part, but you should be able to
work on that entirely separately from the first part.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
I''m not sure how your post addresses my issue - are you suggesting that
I don''t need to break the web page into header/body in order to use the
gzip library and that my problem is elsewhere?
<mw*****@gmail.com> wrote:I''m not sure how your post addresses my issue - are you suggesting that
I don''t need to break the web page into header/body in order to use the
gzip library and that my problem is elsewhere?
I''m suggesting that you should try to make sure you can successfully
transmit/receive arbitrary binary data to work out whether that''s the
problem or whether it''s the gzipping that''s the problem.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
这篇关于ICSharpCode.SharpZipLib.GZip.GZipInputStream与HTTP请求一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!