[Python-checkins] python/dist/src/Lib/logging handlers.py, 1.21, 1.22

vsajip@users.sourceforge.net vsajip at users.sourceforge.net
Tue Oct 11 15:15:34 CEST 2005


Update of /cvsroot/python/python/dist/src/Lib/logging
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17965

Modified Files:
	handlers.py 
Log Message:
Added Host and Content-type headers to requests sent by HTTPHandler (suggested by Steven Vereecken)

Index: handlers.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/logging/handlers.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- handlers.py	13 Mar 2005 09:56:36 -0000	1.21
+++ handlers.py	11 Oct 2005 13:15:31 -0000	1.22
@@ -854,7 +854,8 @@
         """
         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 @@
                     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":



More information about the Python-checkins mailing list