Files
requests3/requests/defaults.py
T
John Szakmeister ed642cfb6d Add the ability to turn off HTTP 0.9 support.
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.
2012-12-02 11:25:18 -05:00

52 lines
1.6 KiB
Python

# -*- coding: utf-8 -*-
"""
requests.defaults
~~~~~~~~~~~~~~~~~
This module provides the Requests configuration defaults.
Configurations:
:base_headers: Default HTTP headers.
:verbose: Stream to write request logging to.
:max_redirects: Maximum number of redirects allowed within a request.s
:keep_alive: Reuse HTTP Connections?
:max_retries: The number of times a request should be retried in the event of a connection failure.
:danger_mode: If true, Requests will raise errors immediately.
:safe_mode: If true, Requests will catch all errors.
:strict_mode: If true, Requests will do its best to follow RFCs (e.g. POST redirects).
:pool_maxsize: The maximium size of an HTTP connection pool.
:pool_connections: The number of active HTTP connection pools to use.
:encode_uri: If true, URIs will automatically be percent-encoded.
:trust_env: If true, the surrouding environment will be trusted (environ, netrc).
:store_cookies: If false, the received cookies as part of the HTTP response would be ignored.
"""
SCHEMAS = ['http', 'https']
from .utils import default_user_agent
defaults = dict()
defaults['base_headers'] = {
'User-Agent': default_user_agent(),
'Accept-Encoding': ', '.join(('gzip', 'deflate', 'compress')),
'Accept': '*/*'
}
defaults['verbose'] = None
defaults['max_redirects'] = 30
defaults['pool_connections'] = 10
defaults['pool_maxsize'] = 10
defaults['max_retries'] = 0
defaults['danger_mode'] = False
defaults['safe_mode'] = False
defaults['strict_mode'] = False
defaults['keep_alive'] = True
defaults['encode_uri'] = True
defaults['trust_env'] = True
defaults['store_cookies'] = True
defaults['support_http0.9'] = True