[Python-3000-checkins] r56905 - python/branches/py3k/Lib/BaseHTTPServer.py

Guido van Rossum guido at python.org
Fri Aug 10 20:59:27 CEST 2007


Yay! This fixes test_urllib2_localnet. We're now down to test_bsddb3
and the three email package tests, plus various things not behaving
yet under torture (regrtest.py -R4:3:).

On 8/10/07, jeremy.hylton <python-3000-checkins at python.org> wrote:
> Author: jeremy.hylton
> Date: Fri Aug 10 20:49:32 2007
> New Revision: 56905
>
> Modified:
>    python/branches/py3k/Lib/BaseHTTPServer.py
> Log:
> Allow rfc822 to process headers from an incoming HTTP request.
>
>
> Modified: python/branches/py3k/Lib/BaseHTTPServer.py
> ==============================================================================
> --- python/branches/py3k/Lib/BaseHTTPServer.py  (original)
> +++ python/branches/py3k/Lib/BaseHTTPServer.py  Fri Aug 10 20:49:32 2007
> @@ -70,6 +70,7 @@
>
>  __all__ = ["HTTPServer", "BaseHTTPRequestHandler"]
>
> +import io
>  import sys
>  import time
>  import socket # For gethostbyaddr()
> @@ -278,7 +279,13 @@
>          self.command, self.path, self.request_version = command, path, version
>
>          # Examine the headers and look for a Connection directive
> -        self.headers = self.MessageClass(self.rfile, 0)
> +        # MessageClass == rfc822 expects ascii, so use a text wrapper.
> +        text = io.TextIOWrapper(self.rfile)
> +        self.headers = self.MessageClass(text, 0)
> +        # The text wrapper does buffering (as does self.rfile).  We
> +        # don't want to leave any data in the buffer of the text
> +        # wrapper.
> +        assert not text.buffer.peek()
>
>          conntype = self.headers.get('Connection', "")
>          if conntype.lower() == 'close':
> _______________________________________________
> Python-3000-checkins mailing list
> Python-3000-checkins at python.org
> http://mail.python.org/mailman/listinfo/python-3000-checkins
>


-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000-checkins mailing list