|
29 | 29 | )
|
30 | 30 | from pip._internal.network.download import (
|
31 | 31 | _get_http_response_filename,
|
| 32 | + _http_get_download, |
32 | 33 | _prepare_download,
|
33 | 34 | )
|
34 |
| -from pip._internal.network.session import PipSession |
35 | 35 | from pip._internal.utils.compat import expanduser
|
36 | 36 | from pip._internal.utils.filesystem import copy2_fixed
|
37 | 37 | from pip._internal.utils.hashes import MissingHashes
|
|
61 | 61 | from pip._internal.distributions import AbstractDistribution
|
62 | 62 | from pip._internal.index.package_finder import PackageFinder
|
63 | 63 | from pip._internal.models.link import Link
|
| 64 | + from pip._internal.network.session import PipSession |
64 | 65 | from pip._internal.req.req_install import InstallRequirement
|
65 | 66 | from pip._internal.req.req_tracker import RequirementTracker
|
66 | 67 | from pip._internal.utils.hashes import Hashes
|
@@ -306,37 +307,6 @@ def unpack_url(
|
306 | 307 | )
|
307 | 308 |
|
308 | 309 |
|
309 |
| -def _http_get_download(session, link): |
310 |
| - # type: (PipSession, Link) -> Response |
311 |
| - target_url = link.url.split('#', 1)[0] |
312 |
| - resp = session.get( |
313 |
| - target_url, |
314 |
| - # We use Accept-Encoding: identity here because requests |
315 |
| - # defaults to accepting compressed responses. This breaks in |
316 |
| - # a variety of ways depending on how the server is configured. |
317 |
| - # - Some servers will notice that the file isn't a compressible |
318 |
| - # file and will leave the file alone and with an empty |
319 |
| - # Content-Encoding |
320 |
| - # - Some servers will notice that the file is already |
321 |
| - # compressed and will leave the file alone and will add a |
322 |
| - # Content-Encoding: gzip header |
323 |
| - # - Some servers won't notice anything at all and will take |
324 |
| - # a file that's already been compressed and compress it again |
325 |
| - # and set the Content-Encoding: gzip header |
326 |
| - # By setting this to request only the identity encoding We're |
327 |
| - # hoping to eliminate the third case. Hopefully there does not |
328 |
| - # exist a server which when given a file will notice it is |
329 |
| - # already compressed and that you're not asking for a |
330 |
| - # compressed file and will then decompress it before sending |
331 |
| - # because if that's the case I don't think it'll ever be |
332 |
| - # possible to make this work. |
333 |
| - headers={"Accept-Encoding": "identity"}, |
334 |
| - stream=True, |
335 |
| - ) |
336 |
| - resp.raise_for_status() |
337 |
| - return resp |
338 |
| - |
339 |
| - |
340 | 310 | class Download(object):
|
341 | 311 | def __init__(
|
342 | 312 | self,
|
|
0 commit comments