title: How to decode the gzip compressed data returned in a HTTP Response in python?
body: <p>I have created a client/server architecture in python, I take HTTP request from the client which is served by requesting another HTTP server through my code. </p>
  
  <p>When I get the response from the third server I am not able to decode the gzip compressed data, I first split the response data using <code>\r\n</code> as separation character which got me the data as the last item in the list then I tried decompressing it with </p>
  
  <pre><code>zlib.decompress(data[-1]) 
  </code></pre>
  
  <p>but it is giving me an error of incorrect headers. How should I go with this problem ?</p>
  
  <p>Code</p>
  
  <pre><code>client_reply = ''
                   while 1:
                       chunk = server2.recv(512)
                       if len(chunk) :
                           client.send(chunk)
                           client_reply += chunk
                       else:
                           break
                   client_split = client_reply.split("\r\n")
                   print client_split[-1].decode('zlib')
  </code></pre>
  
  <p>I want to read the data that is been transferred between the client and the 2nd server.</p>