title: SignalR wth gzip compression
body: <p>Having some problem developing a SignalR client for a Hub hosted in asp.net website with gzip compression enabled. Since we are using IIS compression, the response from SignalR also gets compressed, but, the client does not understand the response and we get a Json parsing error on the client side. </p>
  
  <p>SignalR internally uses <code>HttpWebRequest</code> to make make http requests and <code>HttpWebRequest</code> can be configured to automatically decompress the response using <code>AutomaticDecompression</code> property. So, if somehow I can get hold of the <code>HttpWebRequest</code> object used by SignalR to make the request, I should be able to set the enable automatic decompression.</p>
  
  <p>I thought I should be able to get access to the <code>HttpWebRequest</code> by providing <code>HubConnection.Start</code> with my custom implementation of <code>IHttpClient</code>, <code>IHttpClient.GetAsync</code> takes a <code>prepareRequest</code> action which I thought should give me access to the <code>HttpWebRequest</code>, but, <code>HttpHelper.GetAsync</code> wraps the <code>HttpWebRequest</code> with <code>HttpWebRequestWrapper</code> before passing to <code>prepareRequest</code> and <code>HttpWebRequestWrapper</code> does not provide access to <code>HttpWebRequest</code>. </p>
  
  <p><code>HttpHelper</code> class is internal so can't use it as well, so, I am not exactly sure how to enable automatic decompression with SignalR. </p>
  
  <p>I can expose the <code>HttpWebRequest</code> in <code>HttpWebRequestWrapper</code>, but, would prefer a simpler solution if one exists. Any thougths?</p>
  
  <p>I am using SignalR version 0.5.1.10822</p>
  
  <p>My auto decompression HttpClient:</p>
  
  <pre><code>public class HttpClientWithAutoDecompression : IHttpClient
  {
      readonly DefaultHttpClient _httpClient = new DefaultHttpClient();
  
      private readonly DecompressionMethods _decompressionMethods;
      public HttpClientWithAutoDecompression(DecompressionMethods decompressionMethods)
      {
          _decompressionMethods = decompressionMethods;
      }
  
      public Task&lt;IResponse&gt; GetAsync(string url, Action&lt;IRequest&gt; prepareRequest)
      {
          Task&lt;IResponse&gt; task = _httpClient.GetAsync(url, 
              request =&gt;
                  {
                      [ERROR: request is actually HttpRequestWrapper and
                       does not expose HttpWebRequest]**              ] 
                      var httpWebRequest = (HttpWebRequest) request; 
                      httpWebRequest.AutomaticDecompression = _decompressionMethods;
                      prepareRequest(request);
                  });
  
          return task.ContinueWith(response =&gt;
          {
              Log.Debug(this, "Response: {0}", response.Result.ReadAsString());
              return response.Result;
          });
  
      }
  ....
  }
  </code></pre>