← Back to team overview

beeseek-devs team mailing list archive

[Branch ~beeseek-devs/beeseek/trunk] Rev 203: Cherrypick of revision 213 from lp:~andrea-bs/beeseek/add-script.

 

------------------------------------------------------------
revno: 203
committer: Andrea Corbellini <andrea.corbellini@xxxxxxxxxxx>
branch nick: trunk
timestamp: Sun 2009-01-25 13:26:18 +0100
message:
  Cherrypick of revision 213 from lp:~andrea-bs/beeseek/add-script.
  
  The revision forces the HTTP lib to send the Host header before all 
  other ones. This caused browsers and other applications to return 400 
  errors (Bad Request). It has been discovered most notably on some Ubuntu 
  mirrors.
  
  Users are now able to surf the NET freely, altough some problems still 
  need to be fixed.
modified:
  beeseek/network/http.py

=== modified file 'beeseek/network/http.py'
--- a/beeseek/network/http.py	2009-01-19 19:44:31 +0000
+++ b/beeseek/network/http.py	2009-01-25 12:26:18 +0000
@@ -212,8 +212,17 @@
         :type headers: mapping or iter
         """
         if isinstance(headers, dict):
-            headers = headers.iteritems()
-        self.raw_writelines('%s: %s\r\n' % value for value in headers)
+            if 'Host' in headers:
+                host = headers.pop('Host')
+                self.raw_write('Host: %s\r\n' % host)
+                self.raw_writelines('%s: %s\r\n' % value
+                                    for value in headers.iteritems())
+                headers['Host'] = host
+            else:
+                self.raw_writelines('%s: %s\r\n' % value
+                                    for value in headers.iteritems())
+        else:
+            self.raw_writelines('%s: %s\r\n' % value for value in headers)
         self.raw_write('\r\n')
 
     def _write_chunk(self, data):



--
BeeSeek mainline
https://code.launchpad.net/~beeseek-devs/beeseek/trunk

You are receiving this branch notification because you are subscribed to it.