diff options
author | Helmut Grohne <helmut@subdivi.de> | 2007-04-20 23:46:32 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2007-04-20 23:46:32 +0200 |
commit | 529ab8f8d98ddf9f38b9c1fff8e6410dd8540b69 (patch) | |
tree | b4a3098a705f4ee86fba58babe2097ab7da62742 /wsgitools/middlewares.py | |
parent | dab23d4b5bd904329aa43e4056197e10f7794ca7 (diff) | |
download | wsgitools-529ab8f8d98ddf9f38b9c1fff8e6410dd8540b69.tar.gz |
added better support for HEAD
Diffstat (limited to 'wsgitools/middlewares.py')
-rw-r--r-- | wsgitools/middlewares.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/wsgitools/middlewares.py b/wsgitools/middlewares.py index 5ff610f..ff8120b 100644 --- a/wsgitools/middlewares.py +++ b/wsgitools/middlewares.py @@ -263,15 +263,14 @@ class BasicAuthMiddleware: def authorization_required(self, environ, start_response): """wsgi application for indicating authorization is required.""" status = "401 Authorization required" - headers = [('Content-type', 'text/html'), - ('WWW-Authenticate', 'Basic realm="%s"' % self.realm)] - if environ["REQUEST_METHOD"] == "HEAD": - start_response(status, headers) - return [] html = "<html><head><title>Authorization required</title></head>" + \ "<body><h1>Authorization required</h1></body></html>\n" - headers.append(('Content-length', len(html))) + headers = [('Content-type', 'text/html'), + ('WWW-Authenticate', 'Basic realm="%s"' % self.realm), + ("Content-length", str(len(html)))] start_response(status, headers) + if environ["REQUEST_METHOD"].upper() == "HEAD": + return [] return [html] __all__.append("TracebackMiddleware") @@ -300,4 +299,6 @@ class TracebackMiddleware: data = cgitb.html(exc_info) start_response("200 OK", [("Content-type", "text/html"), ("Content-length", str(len(data)))]) + if environ["REQUEST_METHOD"].upper() == "HEAD": + return [] return [data] |