# Path: pyroutes/http/cookies.py
# class RequestCookieHandler(object):
#     """
#     Class for handling all things regarding to cookies in pyroutes request
#     objects.
#     """
# 
#     def __init__(self, environ=None):
#         if environ and 'HTTP_COOKIE' in environ:
#             self._raw_cookies = dict(
#                     [part.strip() for part in c.split('=', 1)]
#                     for c in environ['HTTP_COOKIE'].split(';'))
#         else:
#             self._raw_cookies = {}
# 
#     def __repr__(self):
#         return u'%s' % self._raw_cookies
# 
#     def get_cookie(self, key):
#         """
#         Return a signed cookie value if it exists.
#         """
#         if key in self._raw_cookies:
#             if '%s_hash' % key in self._raw_cookies:
#                 if settings.SECRET_KEY is None:
#                     raise CookieKeyMissing(
#                             'Set SECRET_KEY in settings to use cookies')
#                 cookie_hash = self._raw_cookies['%s_hash' % key]
#                 value_hash = hmac.HMAC(settings.SECRET_KEY, key +
#                                        self._raw_cookies[key], sha1).hexdigest()
#                 if cookie_hash == value_hash:
#                     return self._raw_cookies[key]
#                 else:
#                     raise CookieHashInvalid(key, 'Cookie modified')
#             else:
#                 raise CookieHashMissing(key, 'Cookie hash missing')
#         else:
#             return None
# 
#     def get_unsigned_cookie(self, key):
#         """
#         Return an unsigned cookie value. (Plain old-fashion cookie reading)
#         """
#         if key in self._raw_cookies:
#             return self._raw_cookies[key]
#         else:
#             return None


from cgi import parse_qsl, FieldStorage
from pyroutes.http.cookies import RequestCookieHandler
    from cStringIO import StringIO
    from StringIO import StringIO
# encoding: utf-8

"""
This module contains only the Request class, a key class in pyroutes. Request
objects hold all meta about incoming requests.
"""



try:
except ImportError:

class Request(object):
    """
    The pyroutes Request object.
    Contains all information about a request,
    like GET/POST and environment data.
    """

    def __init__(self, environment):
        self.GET = {}
        self.POST = {}
        self.PUT = {}
        self.FILES = {}
        self.ENV = environment

        self.extract_get_data()
        self.extract_post_data()
        self.extract_put_data()


# Path: pyroutes/http/cookies.py
# class RequestCookieHandler(object):
#     """
#     Class for handling all things regarding to cookies in pyroutes request
#     objects.
#     """
# 
#     def __init__(self, environ=None):
#         if environ and 'HTTP_COOKIE' in environ:
#             self._raw_cookies = dict(
#                     [part.strip() for part in c.split('=', 1)]
#                     for c in environ['HTTP_COOKIE'].split(';'))
#         else:
#             self._raw_cookies = {}
# 
#     def __repr__(self):
#         return u'%s' % self._raw_cookies
# 
#     def get_cookie(self, key):
#         """
#         Return a signed cookie value if it exists.
#         """
#         if key in self._raw_cookies:
#             if '%s_hash' % key in self._raw_cookies:
#                 if settings.SECRET_KEY is None:
#                     raise CookieKeyMissing(
#                             'Set SECRET_KEY in settings to use cookies')
#                 cookie_hash = self._raw_cookies['%s_hash' % key]
#                 value_hash = hmac.HMAC(settings.SECRET_KEY, key +
#                                        self._raw_cookies[key], sha1).hexdigest()
#                 if cookie_hash == value_hash:
#                     return self._raw_cookies[key]
#                 else:
#                     raise CookieHashInvalid(key, 'Cookie modified')
#             else:
#                 raise CookieHashMissing(key, 'Cookie hash missing')
#         else:
#             return None
# 
#     def get_unsigned_cookie(self, key):
#         """
#         Return an unsigned cookie value. (Plain old-fashion cookie reading)
#         """
#         if key in self._raw_cookies:
#             return self._raw_cookies[key]
#         else:
#             return None


# Path: pyroutes/http/request.py
from cgi import parse_qsl, FieldStorage
from pyroutes.http.cookies import RequestCookieHandler
    from cStringIO import StringIO
    from StringIO import StringIO

# encoding: utf-8

"""
This module contains only the Request class, a key class in pyroutes. Request
objects hold all meta about incoming requests.
"""



try:
except ImportError:

class Request(object):
    """
    The pyroutes Request object.
    Contains all information about a request,
    like GET/POST and environment data.
    """

    def __init__(self, environment):
        self.GET = {}
        self.POST = {}
        self.PUT = {}
        self.FILES = {}
        self.ENV = environment

        self.extract_get_data()
        self.extract_post_data()
        self.extract_put_data()


        self.COOKIES = RequestCookieHandler(environment)