requests_middleware.middleware.MiddlewareHTTPAdapter

Here are the examples of the python api requests_middleware.middleware.MiddlewareHTTPAdapter taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

14 Examples 7

Example 1

View license
@pytest.fixture
def session():
    session = requests.Session()
    adapter = MiddlewareHTTPAdapter()
    cache_middleware = cachecontrolware.CacheMiddleware()
    adapter.register(cache_middleware)
    session.mount('http://', adapter)
    session.mount('https://', adapter)
    return session

Example 2

View license
@pytest.fixture
def session():
    session = requests.Session()
    adapter = MiddlewareHTTPAdapter()
    cache_middleware = cachecontrolware.CacheMiddleware()
    adapter.register(cache_middleware)
    session.mount('http://', adapter)
    session.mount('https://', adapter)
    return session

Example 3

View license
@pytest.fixture
def session():
    session = requests.Session()
    adapter = MiddlewareHTTPAdapter()
    cache_middleware = httpcacheware.CacheMiddleware()
    adapter.register(cache_middleware)
    session.mount('http://', adapter)
    session.mount('https://', adapter)
    return session

Example 4

Project: requests-middleware
Source File: test_multi.py
View license
@pytest.fixture
def session():
    session = requests.Session()
    robots_middleware = robotware.RobotsMiddleware()
    ssl_middleware = sslware.SSLMiddleware(ssl.PROTOCOL_TLSv1)
    middlewares = [robots_middleware, ssl_middleware]
    adapter = MiddlewareHTTPAdapter(middlewares=middlewares)
    session.mount('http://', adapter)
    session.mount('https://', adapter)
    return session

Example 5

View license
@pytest.fixture
def session():
    session = requests.Session()
    adapter = MiddlewareHTTPAdapter()
    cache_middleware = httpcacheware.CacheMiddleware()
    adapter.register(cache_middleware)
    session.mount('http://', adapter)
    session.mount('https://', adapter)
    return session

Example 6

Project: requests-middleware
Source File: test_multi.py
View license
@pytest.fixture
def session():
    session = requests.Session()
    robots_middleware = robotware.RobotsMiddleware()
    ssl_middleware = sslware.SSLMiddleware(ssl.PROTOCOL_TLSv1)
    middlewares = [robots_middleware, ssl_middleware]
    adapter = MiddlewareHTTPAdapter(middlewares=middlewares)
    session.mount('http://', adapter)
    session.mount('https://', adapter)
    return session

Example 7

Project: requests-middleware
Source File: test_robots.py
View license
@pytest.fixture
def session():
    session = requests.Session()
    session.headers['User-Agent'] = 'robot'
    adapter = MiddlewareHTTPAdapter()
    robots_middleware = robotware.RobotsMiddleware()
    adapter.register(robots_middleware)
    session.mount('http://', adapter)
    session.mount('https://', adapter)
    return session

Example 8

Project: requests-middleware
Source File: test_robots.py
View license
@pytest.fixture
def session():
    session = requests.Session()
    session.headers['User-Agent'] = 'robot'
    adapter = MiddlewareHTTPAdapter()
    robots_middleware = robotware.RobotsMiddleware()
    adapter.register(robots_middleware)
    session.mount('http://', adapter)
    session.mount('https://', adapter)
    return session

Example 9

Project: requests-middleware
Source File: test_source.py
View license
@pytest.fixture
def session():
    session = requests.Session()
    source_middleware = sourceware.SourceMiddleware('localhost', 8080)
    middlewares = [source_middleware]
    adapter = MiddlewareHTTPAdapter(middlewares=middlewares)
    session.mount('http://', adapter)
    session.mount('https://', adapter)
    return session

Example 10

Project: requests-middleware
Source File: test_ssl.py
View license
@pytest.fixture
def session():
    session = requests.Session()
    ssl_middleware = sslware.SSLMiddleware(ssl.PROTOCOL_TLSv1)
    middlewares = [ssl_middleware]
    adapter = MiddlewareHTTPAdapter(middlewares=middlewares)
    session.mount('http://', adapter)
    session.mount('https://', adapter)
    return session

Example 11

Project: requests-middleware
Source File: test_source.py
View license
@pytest.fixture
def session():
    session = requests.Session()
    source_middleware = sourceware.SourceMiddleware('localhost', 8080)
    middlewares = [source_middleware]
    adapter = MiddlewareHTTPAdapter(middlewares=middlewares)
    session.mount('http://', adapter)
    session.mount('https://', adapter)
    return session

Example 12

Project: requests-middleware
Source File: test_ssl.py
View license
@pytest.fixture
def session():
    session = requests.Session()
    ssl_middleware = sslware.SSLMiddleware(ssl.PROTOCOL_TLSv1)
    middlewares = [ssl_middleware]
    adapter = MiddlewareHTTPAdapter(middlewares=middlewares)
    session.mount('http://', adapter)
    session.mount('https://', adapter)
    return session

Example 13

View license
def make_session_fixture(throttler):
    @pytest.fixture
    def fixture():
        session = requests.Session()
        adapter = MiddlewareHTTPAdapter()
        throttle_middleware = throttleware.ThrottleMiddleware(throttler)
        adapter.register(throttle_middleware)
        session.mount('http://', adapter)
        session.mount('https://', adapter)
        return session
    return fixture

Example 14

View license
def make_session_fixture(throttler):
    @pytest.fixture
    def fixture():
        session = requests.Session()
        adapter = MiddlewareHTTPAdapter()
        throttle_middleware = throttleware.ThrottleMiddleware(throttler)
        adapter.register(throttle_middleware)
        session.mount('http://', adapter)
        session.mount('https://', adapter)
        return session
    return fixture