summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2013-09-08 16:54:33 (GMT)
committerJason R. Coombs <jaraco@jaraco.com>2013-09-08 16:54:33 (GMT)
commitaae6a1d76fd1336137981cd66acded01d3c36f09 (patch)
treebdfecdb33b99c77ef3eacd4ac4f14e28772acc64
parent7dc4f4bbab494f8d9200678bc7df2de89079317c (diff)
downloadcpython-aae6a1d76fd1336137981cd66acded01d3c36f09.zip
cpython-aae6a1d76fd1336137981cd66acded01d3c36f09.tar.gz
cpython-aae6a1d76fd1336137981cd66acded01d3c36f09.tar.bz2
Issue #18978: A more elegant technique for resolving the method
-rw-r--r--Lib/urllib/request.py8
1 files changed, 2 insertions, 6 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
index 049f48d..bceb329 100644
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -321,12 +321,8 @@ class Request:
def get_method(self):
"""Return a string indicating the HTTP request method."""
- if getattr(self, 'method', None) 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