# Path: openid/fetchers.py
# USER_AGENT = "python-openid/%s (%s)" % (openid.__version__, sys.platform)
# MAX_RESPONSE_KB = 1024
#     ALLOWED_TIME = 20  # seconds
# def fetch(url, body=None, headers=None):
# def createHTTPFetcher():
# def getDefaultFetcher():
# def setDefaultFetcher(fetcher, wrap_exceptions=True):
# def usingCurl():
#     def __init__(self, final_url=None, status=None, headers=None, body=None):
#     def __repr__(self):
#     def fetch(self, url, body=None, headers=None):
# def _allowedURL(url):
#     def __init__(self, why=None):
#     def __init__(self, fetcher):
#     def fetch(self, *args, **kwargs):
#     def fetch(self, url, body=None, headers=None):
#     def _makeResponse(self, urllib_response):
#     def __init__(self):
#     def _parseHeaders(self, header_file):
#     def _checkURL(self, url):
#     def fetch(self, url, body=None, headers=None):
#                 def write_data(chunk):
#     def __init__(self, cache=None):
#     def fetch(self, url, body=None, headers=None):
#     def fetch(self, url, body=None, headers=None):
# class HTTPResponse(object):
# class HTTPFetcher(object):
# class HTTPFetchingError(Exception):
# class ExceptionWrappingFetcher(HTTPFetcher):
# class Urllib2Fetcher(HTTPFetcher):
# class HTTPError(HTTPFetchingError):
# class CurlHTTPFetcher(HTTPFetcher):
# class HTTPLib2Fetcher(HTTPFetcher):
# class RequestsFetcher(HTTPFetcher):


import socket
import unittest
import warnings
import responses
import six
    import requests
        import threading
from mock import Mock, patch, sentinel
from six import StringIO
from six.moves.BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from six.moves.urllib.error import HTTPError, URLError
from six.moves.urllib.request import BaseHandler, OpenerDirector, install_opener
from six.moves.urllib.response import addinfourl
from openid import fetchers
    from requests.exceptions import ConnectionError, InvalidSchema
            response = self.fetcher.fetch('http://example.cz/')
        expected = fetchers.HTTPResponse('http://example.cz/', 200, {'Content-Type': 'text/plain'}, b'BODY')
        assertResponse(expected, response)

    def test_post(self):
        # Test POST response
        with responses.RequestsMock() as rsps:
            rsps.add(responses.POST, 'http://example.cz/', status=200, body=b'BODY',
                     content_type='text/plain')
            response = self.fetcher.fetch('http://example.cz/', body=b'key=value')
        expected = fetchers.HTTPResponse('http://example.cz/', 200, {'Content-Type': 'text/plain'}, b'BODY')
        assertResponse(expected, response)

    def test_redirect(self):
        # Test redirect response - a final response comes from another URL.
        with responses.RequestsMock() as rsps:
            rsps.add(responses.GET, 'http://example.cz/redirect/', status=302,
                     headers={'Location': 'http://example.cz/target/'})
            rsps.add(responses.GET, 'http://example.cz/target/', status=200, body=b'BODY',
                     content_type='text/plain')
            response = self.fetcher.fetch('http://example.cz/redirect/')
        expected = fetchers.HTTPResponse('http://example.cz/target/', 200, {'Content-Type': 'text/plain'}, b'BODY')
        assertResponse(expected, response)

    def test_error(self):
        # Test error responses - returned as obtained
        with responses.RequestsMock() as rsps:
            rsps.add(responses.GET, 'http://example.cz/error/', status=500, body=b'BODY',
                     content_type='text/plain')
            response = self.fetcher.fetch('http://example.cz/error/')

# Path: openid/fetchers.py
# USER_AGENT = "python-openid/%s (%s)" % (openid.__version__, sys.platform)
# MAX_RESPONSE_KB = 1024
#     ALLOWED_TIME = 20  # seconds
# def fetch(url, body=None, headers=None):
# def createHTTPFetcher():
# def getDefaultFetcher():
# def setDefaultFetcher(fetcher, wrap_exceptions=True):
# def usingCurl():
#     def __init__(self, final_url=None, status=None, headers=None, body=None):
#     def __repr__(self):
#     def fetch(self, url, body=None, headers=None):
# def _allowedURL(url):
#     def __init__(self, why=None):
#     def __init__(self, fetcher):
#     def fetch(self, *args, **kwargs):
#     def fetch(self, url, body=None, headers=None):
#     def _makeResponse(self, urllib_response):
#     def __init__(self):
#     def _parseHeaders(self, header_file):
#     def _checkURL(self, url):
#     def fetch(self, url, body=None, headers=None):
#                 def write_data(chunk):
#     def __init__(self, cache=None):
#     def fetch(self, url, body=None, headers=None):
#     def fetch(self, url, body=None, headers=None):
# class HTTPResponse(object):
# class HTTPFetcher(object):
# class HTTPFetchingError(Exception):
# class ExceptionWrappingFetcher(HTTPFetcher):
# class Urllib2Fetcher(HTTPFetcher):
# class HTTPError(HTTPFetchingError):
# class CurlHTTPFetcher(HTTPFetcher):
# class HTTPLib2Fetcher(HTTPFetcher):
# class RequestsFetcher(HTTPFetcher):


# Path: openid/test/test_fetchers.py
import socket
import unittest
import warnings
import responses
import six
    import requests
        import threading
from mock import Mock, patch, sentinel
from six import StringIO
from six.moves.BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
from six.moves.urllib.error import HTTPError, URLError
from six.moves.urllib.request import BaseHandler, OpenerDirector, install_opener
from six.moves.urllib.response import addinfourl
from openid import fetchers
    from requests.exceptions import ConnectionError, InvalidSchema

            response = self.fetcher.fetch('http://example.cz/')
        expected = fetchers.HTTPResponse('http://example.cz/', 200, {'Content-Type': 'text/plain'}, b'BODY')
        assertResponse(expected, response)

    def test_post(self):
        # Test POST response
        with responses.RequestsMock() as rsps:
            rsps.add(responses.POST, 'http://example.cz/', status=200, body=b'BODY',
                     content_type='text/plain')
            response = self.fetcher.fetch('http://example.cz/', body=b'key=value')
        expected = fetchers.HTTPResponse('http://example.cz/', 200, {'Content-Type': 'text/plain'}, b'BODY')
        assertResponse(expected, response)

    def test_redirect(self):
        # Test redirect response - a final response comes from another URL.
        with responses.RequestsMock() as rsps:
            rsps.add(responses.GET, 'http://example.cz/redirect/', status=302,
                     headers={'Location': 'http://example.cz/target/'})
            rsps.add(responses.GET, 'http://example.cz/target/', status=200, body=b'BODY',
                     content_type='text/plain')
            response = self.fetcher.fetch('http://example.cz/redirect/')
        expected = fetchers.HTTPResponse('http://example.cz/target/', 200, {'Content-Type': 'text/plain'}, b'BODY')
        assertResponse(expected, response)

    def test_error(self):
        # Test error responses - returned as obtained
        with responses.RequestsMock() as rsps:
            rsps.add(responses.GET, 'http://example.cz/error/', status=500, body=b'BODY',
                     content_type='text/plain')
            response = self.fetcher.fetch('http://example.cz/error/')

        expected = fetchers.HTTPResponse('http://example.cz/error/', 500, {'Content-Type': 'text/plain'}, b'BODY')