Skip to content

Commit

Permalink
Do not raise an exception if the header instance is not the correct t…
Browse files Browse the repository at this point in the history
…ype on app engine. App Engine uses its own httplib, which are (generally) compatible with standard httplib, but with different names. Addresses urllib3#1501.
  • Loading branch information
speedplane committed Dec 19, 2018
1 parent f80ff34 commit 8b02321
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CONTRIBUTORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -272,5 +272,8 @@ In chronological order:
* Justin Bramley <https://github.com/jbramleycl>
* Add ability to handle multiple Content-Encodings

* Michael Sander (speedplane) <michael.sander@docketalarm.com>
* Quiet warning on App Engine.

* [Your name or handle] <[email or website]>
* [Brief summary of your changes]
5 changes: 3 additions & 2 deletions src/urllib3/util/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from ..packages.six.moves import http_client as httplib

from ..exceptions import HeaderParsingError

from ..contrib import _appengine_environ

def is_fp_closed(obj):
"""
Expand Down Expand Up @@ -51,7 +51,8 @@ def assert_header_parsing(headers):

# This will fail silently if we pass in the wrong kind of parameter.
# To make debugging easier add an explicit check.
if not isinstance(headers, httplib.HTTPMessage):
if not _appengine_environ.is_appengine() and \
not isinstance(headers, httplib.HTTPMessage):
raise TypeError('expected httplib.Message, got {0}.'.format(
type(headers)))

Expand Down

0 comments on commit 8b02321

Please sign in to comment.