Skip to content

Instantly share code, notes, and snippets.

@bcse bcse/request.py
Created Mar 18, 2013

Embed
What would you like to do?
Extending urllib2.Request, so we can assign HTTP verb manually.
from urllib2 import Request as RequestBase
class Request(RequestBase):
def __init__(self, url, data=None, headers=None, origin_req_host=None,
unverifiable=False, method=None):
if headers is None:
headers = {}
super(Request, self).__init__(url, data, headers, origin_req_host, unverifiable)
self.method = method
def get_method(self):
if self.method is not None:
return self.method
else:
return super(Request, self).get_method()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.