# Path: pyoauth/http.py
# class ResponseAdapter(object):
#     """Adaptor HTTP Response class.
# 
#     Framework implementers can subclass this class and must use it with
#     the client methods for them to work.
#     """
#     def __init__(self, status, reason, body, headers=None):
#         self._body = body
#         self._status = status
#         self._reason = reason
#         self._headers = headers or {}
# 
#     @property
#     def body(self):
#         """Payload from the response."""
#         return self._body
# 
#     @property
#     def payload(self):
#         """Payload from the response."""
#         return self._body
# 
#     @property
#     def content(self):
#         """Payload from the response."""
#         return self._body
# 
#     @property
#     def error(self):
#         """
#         Determines whether an error occurred. ``True`` or ``False``.
#         """
#         return self.status < 200 or self.status >= 300
# 
#     @property
#     def status(self):
#         """The HTTP response status code."""
#         return self._status
# 
#     @property
#     def reason(self):
#         """The HTTP response status message."""
#         return self._reason
# 
#     @property
#     def headers(self):
#         """HTTP response headers."""
#         return self._headers
# 
#     def get_header(self, name):
#         """
#         Fetches the value of a header with the given name.
# 
#         :param name:
#             The name of the header.
#         :returns:
#             Value of the header.
#         """
#         if name in self.headers:
#             return self.headers[name]
#         elif name.lower() in self.headers:
#             return self.headers[name.lower()]
#         else:
#             header_lowercased = name.lower()
#             for k, v in self.headers.items():
#                 if k.lower() == header_lowercased:
#                     return v
#             return None
# 
#     @property
#     def content_type(self):
#         """Determines the content type of the response."""
#         return self.get_header(HEADER_CONTENT_TYPE_CAPS).split(SYMBOL_SEMICOLON, 1)[0]
# 
#     def is_body_form_urlencoded(self):
#         """Determines whether the response has content type form urlencoded."""
#         return self.content_type == CONTENT_TYPE_FORM_URLENCODED
# 
#     @property
#     def content_type_encoding(self):
#         """Determines the content type of the response."""
#         header = self.get_header(HEADER_CONTENT_TYPE_CAPS)
#         if SYMBOL_SEMICOLON in header:
#             content_type, encoding = header.split(SYMBOL_SEMICOLON, 1)
#             if encoding:
#                 return encoding.strip().split(SYMBOL_EQUAL, 1)[1]
#             else:
#                 return None
#         else:
#             return None


import logging
from functools import partial
from google.appengine.api import urlfetch
from pyoauth.http import ResponseAdapter
from vendor.mom.mom.builtins import b
        """
        Fetches a response from the OAuth server for a given OAuth request.

        Self-contained HTTP request method can be replaced with
        one for your Web framework.

        :param request:
            An instance of type :class:`pyoauth.http.RequestProxy`.
        :param async_callback:
            ``None`` by default. Unused on App Engine. Useful when your request
            fetching method is asynchronous. Set to a callback function which
            has the following signature::

                def handle_response(response):
                    pass

            If callback is not set, the response is returned by the method.
        :param args:
            Any additional positional arguments to be passed to the
            ``async_callback``.
        :param kwargs:
            Any additional arguments to be passed to the ``async_callback``.
        """
        if async_callback:
            http = _AsyncHttpClient()

            if args or kwargs:
                async_callback = partial(async_callback, *args, **kwargs)

            def adapt_response(response):

# Path: pyoauth/http.py
# class ResponseAdapter(object):
#     """Adaptor HTTP Response class.
# 
#     Framework implementers can subclass this class and must use it with
#     the client methods for them to work.
#     """
#     def __init__(self, status, reason, body, headers=None):
#         self._body = body
#         self._status = status
#         self._reason = reason
#         self._headers = headers or {}
# 
#     @property
#     def body(self):
#         """Payload from the response."""
#         return self._body
# 
#     @property
#     def payload(self):
#         """Payload from the response."""
#         return self._body
# 
#     @property
#     def content(self):
#         """Payload from the response."""
#         return self._body
# 
#     @property
#     def error(self):
#         """
#         Determines whether an error occurred. ``True`` or ``False``.
#         """
#         return self.status < 200 or self.status >= 300
# 
#     @property
#     def status(self):
#         """The HTTP response status code."""
#         return self._status
# 
#     @property
#     def reason(self):
#         """The HTTP response status message."""
#         return self._reason
# 
#     @property
#     def headers(self):
#         """HTTP response headers."""
#         return self._headers
# 
#     def get_header(self, name):
#         """
#         Fetches the value of a header with the given name.
# 
#         :param name:
#             The name of the header.
#         :returns:
#             Value of the header.
#         """
#         if name in self.headers:
#             return self.headers[name]
#         elif name.lower() in self.headers:
#             return self.headers[name.lower()]
#         else:
#             header_lowercased = name.lower()
#             for k, v in self.headers.items():
#                 if k.lower() == header_lowercased:
#                     return v
#             return None
# 
#     @property
#     def content_type(self):
#         """Determines the content type of the response."""
#         return self.get_header(HEADER_CONTENT_TYPE_CAPS).split(SYMBOL_SEMICOLON, 1)[0]
# 
#     def is_body_form_urlencoded(self):
#         """Determines whether the response has content type form urlencoded."""
#         return self.content_type == CONTENT_TYPE_FORM_URLENCODED
# 
#     @property
#     def content_type_encoding(self):
#         """Determines the content type of the response."""
#         header = self.get_header(HEADER_CONTENT_TYPE_CAPS)
#         if SYMBOL_SEMICOLON in header:
#             content_type, encoding = header.split(SYMBOL_SEMICOLON, 1)
#             if encoding:
#                 return encoding.strip().split(SYMBOL_EQUAL, 1)[1]
#             else:
#                 return None
#         else:
#             return None


# Path: pyoauth/appengine/httpclient.py
import logging
from functools import partial
from google.appengine.api import urlfetch
from pyoauth.http import ResponseAdapter
from vendor.mom.mom.builtins import b

        """
        Fetches a response from the OAuth server for a given OAuth request.

        Self-contained HTTP request method can be replaced with
        one for your Web framework.

        :param request:
            An instance of type :class:`pyoauth.http.RequestProxy`.
        :param async_callback:
            ``None`` by default. Unused on App Engine. Useful when your request
            fetching method is asynchronous. Set to a callback function which
            has the following signature::

                def handle_response(response):
                    pass

            If callback is not set, the response is returned by the method.
        :param args:
            Any additional positional arguments to be passed to the
            ``async_callback``.
        :param kwargs:
            Any additional arguments to be passed to the ``async_callback``.
        """
        if async_callback:
            http = _AsyncHttpClient()

            if args or kwargs:
                async_callback = partial(async_callback, *args, **kwargs)

            def adapt_response(response):

                async_callback(ResponseAdapter(response.status_code,