]> granicus.if.org Git - python/commitdiff
Issue #18978: Allow Request.method to be defined at the class level.
authorJason R. Coombs <jaraco@jaraco.com>
Sun, 8 Sep 2013 16:47:07 +0000 (12:47 -0400)
committerJason R. Coombs <jaraco@jaraco.com>
Sun, 8 Sep 2013 16:47:07 +0000 (12:47 -0400)
Lib/urllib/request.py

index 4765a942886d813af8c85d6dcbe3319698f35ce3..049f48d5323e15be6e600ad50fc63811fd088375 100644 (file)
@@ -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,7 +321,7 @@ class Request:
 
     def get_method(self):
         """Return a string indicating the HTTP request method."""
-        if self.method is not None:
+        if getattr(self, 'method', None) is not None:
             return self.method
         elif self.data is not None:
             return "POST"