diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2013-09-22 10:06:24 -0400 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2013-09-22 10:06:24 -0400 |
commit | 838521eed0d90a12b3f387457702f268734ced89 (patch) | |
tree | fee4e3bba92285c4e6bd69f51664cc4053df088b /Lib/urllib/request.py | |
parent | f94a16b494a2b21b8fcb90d666a31f6d78cabc26 (diff) | |
parent | ea9e0974646c045274d3c94c2be9ab019ba2ec8d (diff) | |
download | cpython-git-838521eed0d90a12b3f387457702f268734ced89.tar.gz |
Close #18978: Merge changes.
Diffstat (limited to 'Lib/urllib/request.py')
-rw-r--r-- | Lib/urllib/request.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index 4765a94288..bceb3297c8 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -271,7 +271,8 @@ class Request: origin_req_host = request_host(self) self.origin_req_host = origin_req_host self.unverifiable = unverifiable - self.method = method + if method: + self.method = method @property def full_url(self): @@ -320,12 +321,8 @@ class Request: def get_method(self): """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" + default_method = "POST" if self.data is not None else "GET" + return getattr(self, 'method', default_method) def get_full_url(self): return self.full_url |