]> granicus.if.org Git - python/commitdiff
Issue #18978: A more elegant technique for resolving the method
authorJason R. Coombs <jaraco@jaraco.com>
Sun, 8 Sep 2013 16:54:33 +0000 (12:54 -0400)
committerJason R. Coombs <jaraco@jaraco.com>
Sun, 8 Sep 2013 16:54:33 +0000 (12:54 -0400)
Lib/urllib/request.py

index 049f48d5323e15be6e600ad50fc63811fd088375..bceb3297c8ea89f0c30d8dd5527b4114cb422ad5 100644 (file)
@@ -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