diff options
author | Helmut Grohne <helmut@subdivi.de> | 2008-09-22 19:06:03 +0200 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2008-09-22 19:06:03 +0200 |
commit | 091045c7049f7f851bb8166cac5ecbbf828ca6e2 (patch) | |
tree | d9a8ab95584c911a175b63eac5c2028ea24774a0 /wsgitools/applications.py | |
parent | 2444c54b184a5a9ad89c79d36a456a83e9150d87 (diff) | |
download | wsgitools-091045c7049f7f851bb8166cac5ecbbf828ca6e2.tar.gz |
applications.StaticContent: fail on bad request
Diffstat (limited to 'wsgitools/applications.py')
-rw-r--r-- | wsgitools/applications.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/wsgitools/applications.py b/wsgitools/applications.py index 2e6703c..9112e45 100644 --- a/wsgitools/applications.py +++ b/wsgitools/applications.py @@ -1,6 +1,9 @@ class StaticContent: - """This wsgi application provides static content on whatever request it - receives.""" + """ + This wsgi application provides static content on whatever request it + receives with method GET or HEAD (content stripped). If not present, a + content-length header is computed. + """ def __init__(self, status, headers, content): """ @type status: str @@ -31,6 +34,11 @@ class StaticContent: def __call__(self, environ, start_response): """wsgi interface""" assert isinstance(environ, dict) + if environ["REQUEST_METHOD"].upper() not in ["GET", "HEAD"]: + resp = "Request method not implemented" + start_response("501 Not Implemented", + [("Content-length", str(len(resp)))]) + return [resp] start_response(self.status, self.headers) if environ["REQUEST_METHOD"].upper() == "HEAD": return [] |