[Python-checkins] python/dist/src/Lib/logging handlers.py, 1.19.2.1, 1.19.2.2

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


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

Modified Files:
      Tag: release24-maint
	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.19.2.1
retrieving revision 1.19.2.2
diff -u -d -r1.19.2.1 -r1.19.2.2
--- handlers.py	31 Mar 2005 20:12:55 -0000	1.19.2.1
+++ handlers.py	11 Oct 2005 13:16:46 -0000	1.19.2.2
@@ -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