gzipped data "not a gzipped file", but I think it is
<p>This:</p>

<pre><code>H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/SvVK1+B0oQiAYBMk2JBAEOzBiM3mkuwdaUcjKasqgcplVmVdZhZAzO2dvPfee++999577733ujudTif33/8/XGZkAWz2zkrayZ4hgKrIHz9+fB8/Ih7/Hu8WZXqZ101RLT/7aHe881GaL6fVrFhefPbRuj3fPvjo9zh63FTZ6tHp8jIvq1We0ivL5hE+++yjeduuHt2920zn+SJrxvQVPh9X9cVd/HI315fufqSvvWsK+9bV1dX46h433tvZ2b37e3/x/DUD2i6WTZstp7l7a3bzWx8pok+q2fXR45N5trzIn+fLi3b+1bJoX+XNqlo2in4ILZ80eX1ZTPPfe/zi9M1dAhR5e122R7ufjnce3tvff3x3oEH0C+6XvvKwk98NSY/+H/eQC6mIAQAA
</code></pre>

<p>...is the gzipped body of a HTTP response from a web service. I want to decompress this inside a Python script, so I have used a similar piece of code to that shown in previous posts on here, such as <a href="https://stackoverflow.com/questions/30332485/decompressing-a-gzipped-payload-of-a-packet-with-python">Decompressing a gzipped payload of a packet with Python</a></p>

<p>This is my script:</p>

<pre><code>#!/usr/bin/env python
import logging
import gzip
import StringIO

logging.basicConfig(filename='out.log', level=logging.DEBUG)

compressed_data = 'H4sIAAAAAAAEAO29B2AcSZYlJi9tynt/SvVK1+B0oQiAYBMk2JBAEOzBiM3mkuwdaUcjKasqgcplVmVdZhZAzO2dvPfee++999577733ujudTif33/8/XGZkAWz2zkrayZ4hgKrIHz9+fB8/Ih7/Hu8WZXqZ101RLT/7aHe881GaL6fVrFhefPbRuj3fPvjo9zh63FTZ6tHp8jIvq1We0ivL5hE+++yjeduuHt2920zn+SJrxvQVPh9X9cVd/HI315fufqSvvWsK+9bV1dX46h433tvZ2b37e3/x/DUD2i6WTZstp7l7a3bzWx8pok+q2fXR45N5trzIn+fLi3b+1bJoX+XNqlo2in4ILZ80eX1ZTPPfe/zi9M1dAhR5e122R7ufjnce3tvff3x3oEH0C+6XvvKwk98NSY/+H/eQC6mIAQAA'

logging.debug(compressed_data)

buf = StringIO.StringIO(compressed_data)
f = gzip.GzipFile(fileobj=buf)
decompressed_data = f.read()

logging.debug(decompressed_data)
</code></pre>

<p>...but when I run it, Python reports it is not a gzipped file.</p>

<p>I am pretty sure it is, because when I use <a href="http://www.txtwizard.net/compression" rel="nofollow noreferrer">this online gzip/gunzip utility</a>, the string is correctly decompressed. The HTTP response header also says it is gzip encoded. And, I can also see the decoded contents when I call the service using a testing tool.</p>

<p>I would be interested to know what I have omitted here.</p>

<p>For reference, the decompressed string should be:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;&lt;soap:Body&gt;&lt;ChangeLengthUnitResponse xmlns="http://www.webserviceX.NET/"&gt;&lt;ChangeLengthUnitResult&gt;16.09344&lt;/ChangeLengthUnitResult&gt;&lt;/ChangeLengthUnitResponse&gt;&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;
</code></pre>

<p>I am using Python 2.7.11.</p>