Created
March 18, 2013 02:20
-
-
Save bcse/5184554 to your computer and use it in GitHub Desktop.
Extending urllib2.Request, so we can assign HTTP verb manually.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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