'This is a simple wrapper around a urllib2 request object which helps
with some common tasks like serialization, cache, etc.
:param method: None means choose the default (POST if data is not None)
:param data: The post_data as a string'

def __init__(self, url, data=None, headers=Headers(), origin_req_host=None, unverifiable=False, cookies=True, cache=False, method=None, error_handling=True, retries=MAX_HTTP_RETRIES, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, new_connection=False, follow_redirects=False, use_basic_auth=True, use_proxy=True):

    self.url_object = url
    self.cookies = cookies
    self.get_from_cache = cache
    self.error_handling = error_handling
    self.retries_left = retries
    self.timeout = timeout
    self.new_connection = new_connection
    self.follow_redirects = follow_redirects
    self.use_basic_auth = use_basic_auth
    self.use_proxy = use_proxy
    self.method = method
    if (self.method is None):
        self.method = ('POST' if data else 'GET')
    if isinstance(headers, Headers):
        headers.tokens_to_value()
    headers = dict(headers)
    urllib2.Request.__init__(self, url.url_encode(), data, headers, origin_req_host, unverifiable)
    RequestMixIn.__init__(self)
