title: WP8 Gzip compression
body: <p>WP8 does not support Gzip compression, but there is 3rd party libraries that will allow you do so, i have tried many but i am not able to make it work. this is my latest try:</p>
  
  <p>var handler = new HttpClientHandler();</p>
  
  <pre><code>        if (handler.SupportsAutomaticDecompression)
          {
              handler.AutomaticDecompression = DecompressionMethods.GZip |
                                               DecompressionMethods.Deflate;
          }
  
          Uri myUri = new Uri("http://www.web.com");
  
          HttpClient client = new HttpClient(handler);
  
          client.BaseAddress = myUri;
  
          client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
          client.DefaultRequestHeaders.Add("ubq-compression", "gzip");
  
          HttpRequestMessage req = new HttpRequestMessage(HttpMethod.Post, myUri);
          req.Content = new StringContent(finalURL, Encoding.UTF8);
  
          HttpResponseMessage rm = client.SendAsync(req).Result;
          string rst = await rm.Content.ReadAsStringAsync();
  </code></pre>
  
  <p>the API return to me an array of bytes but the the first 300 are not Gziped but everything else is</p>
  
  <p>i need to unzip everything that comes after the 300 bytes. </p>
  
  <p>i am using the <a href="http://www.nuget.org/packages/Microsoft.Net.Http" rel="nofollow">http://www.nuget.org/packages/Microsoft.Net.Http</a></p>
  
  <p>// i am splitting the array 
  byte[] hJ = res.Take(300).ToArray();
  byte[] bJ = res.Skip(300).ToArray();</p>
  
  <p>bj is what need to be decompressed.</p>
  
  <p>i am trying this </p>
  
  <p>MemoryStream stream = new MemoryStream();
                      stream.Write(bj, 0, bj.Length);</p>
  
  <pre><code>                using (var inStream = new MemoryStream(bj)) 
                  {
                      var bigStreamsss = new GZipStream(inStream, CompressionMode.Decompress, true);
  
                      using (var bigStreamOut = new MemoryStream())
                      {
                          bigStreamsss.CopyTo(bigStreamOut);
                          output = Encoding.UTF8.GetString(bigStreamOut.ToArray(), 0, bigStreamOut.ToArray().Length);
                      }
  
                  }
  </code></pre>
  
  <p>but it is always failing on this line "
                          var bigStreamsss = new GZipStream(inStream, CompressionMode.Decompress, true);
  "</p>
  
  <p>Any help would be much appreciated </p>