Last active
April 20, 2019 06:41
-
-
Save clpo13/93c5f5e63e0f97161aad4621e1586e66 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
321,323c321,326 | |
< # Perform a HEAD request to obtain the Content-Length | |
< r = requests.head(location) | |
< content_length = int(r.headers.get('content-length', 0)) | |
--- | |
> # Perform a request to obtain the Content-Length header | |
> r = requests.get(location, stream=True) | |
> try: | |
> content_length = int(r.headers['content-length']) | |
> except KeyError: | |
> content_length = len(r.content) | |
326c329 | |
< return requests.get(location, stream=True) | |
--- | |
> return r |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment