I have problem like this https://dev.twitter.com/discussions/4563
if (webResponse.Headers["Content-Encoding"] == "gzip")
{
byte[] bytes = UTF8Encoding.Unicode.GetBytes(stream);
MemoryStream ms = new MemoryStream(bytes);
var rstream = new ICSharpCode.SharpZipLib.GZip.GZipInputStream(ms);
using (var reader = new StreamReader(rstream, Encoding.UTF8))
{
var st = reader.ReadToEnd();// Exception here: "Error baseInputStream GZIP header, second byte doesn't match"
parameters = HelperMethods.GetQueryParameters(st);
}
}
I use this lib: http://slsharpziplib.codeplex.com/
Update:
I use RestClient for post tweet only. For login I use:
var AccessTokenQuery = oAuthHelper.GetAccessTokenQuery(OAuthTokenKey, tokenSecret, VerifyPin);
AccessTokenQuery.QueryResponse += new EventHandler<WebQueryResponseEventArgs>(AccessTokenQuery_QueryResponse);
AccessTokenQuery.RequestAsync(TwitterSettings.AccessTokenUri, null);
It looks like the gzip response you are receiving isn’t quite what SharpZipLib is expecting.
The error you are getting is from SharpZipLib/src/GZIP/GzipInputStream.cs and is probably from this line:
Try saving the stream to a file and then take a look at it. See if you can unpack it with 7-zip, etc. Then once you know what’s wrong you can go from there.
Update:
There appears to be a solution to the problem you are having at the end of the discussion you linked to and I wanted to make sure you were aware of it: