pypa/pip — pull request #1644 by coderfi (2014-03-14 01:51:04+00:00)
Title: Fixes a tar file decompression issue "ReadError: not a gzip file" when f...

...etching a *.tar.gz resource

that has already been decompressed.
This fix covers the case when the file server (such as pypiserver behind
nginx) returns the resource with the following headers:
Content-Type: application/x-tar
Content-Encoding: gzip
The underlying http library (or some function post-download)
automatically unzips the tar.gz file (possibly because of the
Content-Encoding hint).
Unfortunately, pip.util naievely relied on the filename extension
to determine whether the file should be decompressed.
In the case of the combination headers above, this would result in
a second unzip attempt and a "ReadError: not a gzip file" would be
raised.
This fix prevents the second unzip attempt by first checking to see
if the Content-Type is a 'application/x-tar' and trust
that the file server transferred a tar file and that the http library
honored the gzip content encoding by automatically unzipping the
downloaded byte stream.
This effectively makes this interaction with the server basically
the same as a regular HTML page fetch when the response is gzip encoded.