]> granicus.if.org Git - python/commitdiff
Issue 4336: Let users of HTTPConnection.endheaders() submit a message body to the...
authorKristján Valur Jónsson <kristjan@ccpgames.com>
Fri, 9 Jan 2009 20:27:16 +0000 (20:27 +0000)
committerKristján Valur Jónsson <kristjan@ccpgames.com>
Fri, 9 Jan 2009 20:27:16 +0000 (20:27 +0000)
Lib/logging/handlers.py
Lib/urllib.py

index 0d347fb79dd508a5b46c29597426560ea9344cc6..9668ebea2e7b1b6a9ddddc1867827c48398284b3 100644 (file)
@@ -1027,9 +1027,7 @@ class HTTPHandler(logging.Handler):
                 h.putheader("Content-type",
                             "application/x-www-form-urlencoded")
                 h.putheader("Content-length", str(len(data)))
-            h.endheaders()
-            if self.method == "POST":
-                h.send(data)
+            h.endheaders(data if self.method == "POST" else None)
             h.getreply()    #can't do anything with the result
         except (KeyboardInterrupt, SystemExit):
             raise
index 38c5ee49f11754ab5d9b50f2524bfcea29a09fa7..d23d0706cc29c6032f6766ef8981f669e20b1bb4 100644 (file)
@@ -335,9 +335,7 @@ class URLopener:
         if auth: h.putheader('Authorization', 'Basic %s' % auth)
         if realhost: h.putheader('Host', realhost)
         for args in self.addheaders: h.putheader(*args)
-        h.endheaders()
-        if data is not None:
-            h.send(data)
+        h.endheaders(data)
         errcode, errmsg, headers = h.getreply()
         fp = h.getfile()
         if errcode == -1:
@@ -430,9 +428,7 @@ class URLopener:
             if auth: h.putheader('Authorization', 'Basic %s' % auth)
             if realhost: h.putheader('Host', realhost)
             for args in self.addheaders: h.putheader(*args)
-            h.endheaders()
-            if data is not None:
-                h.send(data)
+            h.endheaders(data)
             errcode, errmsg, headers = h.getreply()
             fp = h.getfile()
             if errcode == -1: