2015-08-02 18:59:11 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
# __
|
|
|
|
# /__) _ _ _ _ _/ _
|
|
|
|
# / ( (- (/ (/ (- _) / _)
|
|
|
|
# /
|
|
|
|
|
|
|
|
"""
|
2016-11-09 18:24:33 +00:00
|
|
|
Requests HTTP library
|
2015-08-02 18:59:11 +00:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Requests is an HTTP library, written in Python, for human beings. Basic GET
|
|
|
|
usage:
|
|
|
|
|
|
|
|
>>> import requests
|
2016-11-09 18:24:33 +00:00
|
|
|
>>> r = requests.get('https://www.python.org')
|
2015-08-02 18:59:11 +00:00
|
|
|
>>> r.status_code
|
|
|
|
200
|
|
|
|
>>> 'Python is a programming language' in r.content
|
|
|
|
True
|
|
|
|
|
|
|
|
... or POST:
|
|
|
|
|
|
|
|
>>> payload = dict(key1='value1', key2='value2')
|
2016-11-09 18:24:33 +00:00
|
|
|
>>> r = requests.post('http://httpbin.org/post', data=payload)
|
2015-08-02 18:59:11 +00:00
|
|
|
>>> print(r.text)
|
|
|
|
{
|
|
|
|
...
|
|
|
|
"form": {
|
|
|
|
"key2": "value2",
|
|
|
|
"key1": "value1"
|
|
|
|
},
|
|
|
|
...
|
|
|
|
}
|
|
|
|
|
|
|
|
The other HTTP methods are supported - see `requests.api`. Full documentation
|
|
|
|
is at <http://python-requests.org>.
|
|
|
|
|
2016-11-09 18:24:33 +00:00
|
|
|
:copyright: (c) 2016 by Kenneth Reitz.
|
2015-08-02 18:59:11 +00:00
|
|
|
:license: Apache 2.0, see LICENSE for more details.
|
|
|
|
"""
|
|
|
|
|
|
|
|
__title__ = 'requests'
|
2016-11-09 18:24:33 +00:00
|
|
|
__version__ = '2.11.1'
|
|
|
|
__build__ = 0x021101
|
2015-08-02 18:59:11 +00:00
|
|
|
__author__ = 'Kenneth Reitz'
|
|
|
|
__license__ = 'Apache 2.0'
|
2016-11-09 18:24:33 +00:00
|
|
|
__copyright__ = 'Copyright 2016 Kenneth Reitz'
|
2015-08-02 18:59:11 +00:00
|
|
|
|
|
|
|
# Attempt to enable urllib3's SNI support, if possible
|
|
|
|
try:
|
|
|
|
from .packages.urllib3.contrib import pyopenssl
|
|
|
|
pyopenssl.inject_into_urllib3()
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
2016-11-09 18:24:33 +00:00
|
|
|
import warnings
|
|
|
|
|
|
|
|
# urllib3's DependencyWarnings should be silenced.
|
|
|
|
from .packages.urllib3.exceptions import DependencyWarning
|
|
|
|
warnings.simplefilter('ignore', DependencyWarning)
|
|
|
|
|
2015-08-02 18:59:11 +00:00
|
|
|
from . import utils
|
|
|
|
from .models import Request, Response, PreparedRequest
|
|
|
|
from .api import request, get, head, post, patch, put, delete, options
|
|
|
|
from .sessions import session, Session
|
|
|
|
from .status_codes import codes
|
|
|
|
from .exceptions import (
|
|
|
|
RequestException, Timeout, URLRequired,
|
2016-11-09 18:24:33 +00:00
|
|
|
TooManyRedirects, HTTPError, ConnectionError,
|
|
|
|
FileModeWarning, ConnectTimeout, ReadTimeout
|
2015-08-02 18:59:11 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# Set default logging handler to avoid "No handler found" warnings.
|
|
|
|
import logging
|
|
|
|
try: # Python 2.7+
|
|
|
|
from logging import NullHandler
|
|
|
|
except ImportError:
|
|
|
|
class NullHandler(logging.Handler):
|
|
|
|
def emit(self, record):
|
|
|
|
pass
|
|
|
|
|
|
|
|
logging.getLogger(__name__).addHandler(NullHandler())
|
2016-11-09 18:24:33 +00:00
|
|
|
|
|
|
|
# FileModeWarnings go off per the default.
|
|
|
|
warnings.simplefilter('default', FileModeWarning, append=True)
|