Skip to content

Instantly share code, notes, and snippets.

@logic
logic / methodreq.py
Created May 17, 2012 02:26
Adding an HTTP method to urllib2.Request.
import urllib2
class MethodRequest(urllib2.Request):
def __init__(self, *args, **kwargs):
if 'method' in kwargs:
self._method = kwargs['method']
del kwargs['method']
else:
self._method = None
return urllib2.Request.__init__(self, *args, **kwargs)