summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2005-10-11 13:15:31 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2005-10-11 13:15:31 (GMT)
commitb79350601bc3faea4ca97d537ba887810daf0ba0 (patch)
tree2bf8e9bb08094799ebe3c547d488a697822cef1f /Lib
parent116078f0bb900f6f5da3ee0ca6d0c58210528eca (diff)
downloadcpython-b79350601bc3faea4ca97d537ba887810daf0ba0.zip
cpython-b79350601bc3faea4ca97d537ba887810daf0ba0.tar.gz
cpython-b79350601bc3faea4ca97d537ba887810daf0ba0.tar.bz2
Added Host and Content-type headers to requests sent by HTTPHandler (suggested by Steven Vereecken)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/logging/handlers.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index 0801699..0182dfe 100644
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -854,7 +854,8 @@ class HTTPHandler(logging.Handler):
"""
try:
import httplib, urllib
- h = httplib.HTTP(self.host)
+ host = self.host
+ h = httplib.HTTP(host)
url = self.url
data = urllib.urlencode(self.mapLogRecord(record))
if self.method == "GET":
@@ -864,7 +865,15 @@ class HTTPHandler(logging.Handler):
sep = '?'
url = url + "%c%s" % (sep, data)
h.putrequest(self.method, url)
+ # support multiple hosts on one IP address...
+ # need to strip optional :port from host, if present
+ i = string.find(host, ":")
+ if i >= 0:
+ host = host[:i]
+ h.putheader("Host", host)
if self.method == "POST":
+ h.putheader("Content-type",
+ "application/x-www-form-urlencoded")
h.putheader("Content-length", str(len(data)))
h.endheaders()
if self.method == "POST":