Ken Kennedy wrote:
> I've been playing with some of the code from Andrew's Jan-04 thread on
> "Adding support for authentication"
>
> http://mail.mems-exchange.org/pipermail/quixote-users/2004-January/002462.html
>
> and to get basic authentication working with medusa_http.py, I had to
> add a line to the environ dict:
>
> ---
> /usr/lib/python2.3/site-packages/quixote/server/medusa_http_py.orig
> 2004-08-06 23:57:08.000000000 -0400
> +++ /usr/lib/python2.3/site-packages/quixote/server/medusa_http.py
> 2004-08-06 23:35:28.000000000 -0400
> @@ -64,6 +64,7 @@
> 'SERVER_PORT':str(self.server.port),
> 'SERVER_PROTOCOL':'HTTP/1.1',
> 'SERVER_SOFTWARE':self.server_name,
> + 'HTTP_AUTHORIZATION':msg.get('Authorization',None),
> }
> for k,v in environ.items():
> if v == None:
Are you running an older version of Quixote? My local version includes
the following:
# Propagate HTTP headers - copied from twisted_http.py
for title, header in msg.items():
envname = title.replace('-', '_').upper()
if title not in ('content-type', 'content-length'):
envname = "HTTP_" + envname
environ[envname] = header
The "propagate headers" section should have taken care of this for you.
* * *
In re-reading this code, I'm not sure why the exception is made for
HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH. Not a big deal, but why run
the comparison for every header entry, just to get rid of them? Seems
wasteful; and I'd recommend we shorten this to
for title, header in msg.items():
envname = title.replace('-', '_').upper()
envname = "HTTP_" + envname
environ[envname] = header
in both medusa_http and twisted_http.
-- G