Kaydet (Commit) 84040dbe authored tarafından Kristján Valur Jónsson's avatar Kristján Valur Jónsson

Issue 4336: Let users of HTTPConnection.endheaders() submit a message body to…

Issue 4336:  Let users of HTTPConnection.endheaders() submit a message body to the function if required.
üst 7e876f5e
...@@ -1027,9 +1027,7 @@ class HTTPHandler(logging.Handler): ...@@ -1027,9 +1027,7 @@ class HTTPHandler(logging.Handler):
h.putheader("Content-type", h.putheader("Content-type",
"application/x-www-form-urlencoded") "application/x-www-form-urlencoded")
h.putheader("Content-length", str(len(data))) h.putheader("Content-length", str(len(data)))
h.endheaders() h.endheaders(data if self.method == "POST" else None)
if self.method == "POST":
h.send(data)
h.getreply() #can't do anything with the result h.getreply() #can't do anything with the result
except (KeyboardInterrupt, SystemExit): except (KeyboardInterrupt, SystemExit):
raise raise
......
...@@ -335,9 +335,7 @@ class URLopener: ...@@ -335,9 +335,7 @@ class URLopener:
if auth: h.putheader('Authorization', 'Basic %s' % auth) if auth: h.putheader('Authorization', 'Basic %s' % auth)
if realhost: h.putheader('Host', realhost) if realhost: h.putheader('Host', realhost)
for args in self.addheaders: h.putheader(*args) for args in self.addheaders: h.putheader(*args)
h.endheaders() h.endheaders(data)
if data is not None:
h.send(data)
errcode, errmsg, headers = h.getreply() errcode, errmsg, headers = h.getreply()
fp = h.getfile() fp = h.getfile()
if errcode == -1: if errcode == -1:
...@@ -430,9 +428,7 @@ class URLopener: ...@@ -430,9 +428,7 @@ class URLopener:
if auth: h.putheader('Authorization', 'Basic %s' % auth) if auth: h.putheader('Authorization', 'Basic %s' % auth)
if realhost: h.putheader('Host', realhost) if realhost: h.putheader('Host', realhost)
for args in self.addheaders: h.putheader(*args) for args in self.addheaders: h.putheader(*args)
h.endheaders() h.endheaders(data)
if data is not None:
h.send(data)
errcode, errmsg, headers = h.getreply() errcode, errmsg, headers = h.getreply()
fp = h.getfile() fp = h.getfile()
if errcode == -1: if errcode == -1:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment