From 84040dbe8170864ba673321ec7568974bdabf5a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristj=C3=A1n=20Valur=20J=C3=B3nsson?= Date: Fri, 9 Jan 2009 20:27:16 +0000 Subject: Issue 4336: Let users of HTTPConnection.endheaders() submit a message body to the function if required. --- Lib/logging/handlers.py | 4 +--- Lib/urllib.py | 8 ++------ 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index 0d347fb..9668ebe 100644 --- a/Lib/logging/handlers.py +++ b/Lib/logging/handlers.py @@ -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 diff --git a/Lib/urllib.py b/Lib/urllib.py index 38c5ee4..d23d070 100644 --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -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: -- cgit v0.12