Skip to content
Myr

Add the ability to turn off HTTP 0.9 support.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

While debugging an issue I discovered requests was coming back with 200 response, when it really shouldn't have. It turns out this happened for two reasons: the jetty server running the app was rather lame and didn't fail the request as a Bad Request, and httplib was happy to let malformed data through and call it success. It turns out httplib's strict flag controls this behavior of whether or not to validate the status line. The underlying urllib3 supports the concept as well. There was a bug there to that is now fixed upstream. The last step is exposing this through requests. This introduces a supports_http0.9 flag to help control this behavior. It defaults to to True to preserve the current behavior. Setting it to False will allow the underlying HTTPConnection to validate the status line.

authored by John Szakmeister · committed by John Szakmeister · parent 63243b1 · Browse files · 3 files+4 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+4 added−2 removed

  • other:+4 added−2 removed

3 files+4 added−2 removed

modified:requests/api.py+1 added-1 removed
42 unmodified lines
43 # if we're making it just for this call, then close it when we're done.44 adhoc_session = False45 session = kwargs.pop('session', None)46 if session is None:47 session = sessions.session()47 session = sessions.session(config=kwargs.get('config', None))48 adhoc_session = True4950 try:51 return session.request(method=method, url=url, **kwargs)
79 unmodified lines
modified:requests/defaults.py+1 added
46 unmodified lines
47defaults['keep_alive'] = True48defaults['encode_uri'] = True49defaults['trust_env'] = True50defaults['store_cookies'] = True51defaults['support_http0.9'] = True
modified:requests/sessions.py+2 added-1 removed
96 unmodified lines
9798 def init_poolmanager(self):99 self.poolmanager = PoolManager(100 num_pools=self.config.get('pool_connections'),101 maxsize=self.config.get('pool_maxsize')101 maxsize=self.config.get('pool_maxsize'),102 strict=not self.config.get('support_http0.9')103 )104105 def __repr__(self):106 return '<requests-client at 0x%x>' % (id(self))
223 unmodified lines