diff options
author | Senthil Kumaran <senthil@uthcode.com> | 2011-10-16 15:54:44 (GMT) |
---|---|---|
committer | Senthil Kumaran <senthil@uthcode.com> | 2011-10-16 15:54:44 (GMT) |
commit | de49d64dbcfb108e79a0e42f983ebc2df07219a0 (patch) | |
tree | 8ef0e223f4594aabbb62a28fde5dd7a436a0c714 /Lib/urllib/request.py | |
parent | d8886fc831e16ab225f7e474751cc1a7b3cd01df (diff) | |
download | cpython-de49d64dbcfb108e79a0e42f983ebc2df07219a0.zip cpython-de49d64dbcfb108e79a0e42f983ebc2df07219a0.tar.gz cpython-de49d64dbcfb108e79a0e42f983ebc2df07219a0.tar.bz2 |
Fix closes issue 1673007 urllib.request to support HEAD requests with a new method arg.
Diffstat (limited to 'Lib/urllib/request.py')
-rw-r--r-- | Lib/urllib/request.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index a947608..65ce287 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -177,7 +177,8 @@ def request_host(request): class Request: def __init__(self, url, data=None, headers={}, - origin_req_host=None, unverifiable=False): + origin_req_host=None, unverifiable=False, + method=None): # unwrap('<URL:type://host/path>') --> 'type://host/path' self.full_url = unwrap(url) self.full_url, self.fragment = splittag(self.full_url) @@ -191,6 +192,7 @@ class Request: origin_req_host = request_host(self) self.origin_req_host = origin_req_host self.unverifiable = unverifiable + self.method = method self._parse() def _parse(self): @@ -202,7 +204,10 @@ class Request: self.host = unquote(self.host) def get_method(self): - if self.data is not None: + """Return a string indicating the HTTP request method.""" + if self.method is not None: + return self.method + elif self.data is not None: return "POST" else: return "GET" |