summaryrefslogtreecommitdiff
path: root/wsgitools/applications.py
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2008-09-22 19:06:03 +0200
committerHelmut Grohne <helmut@subdivi.de>2008-09-22 19:06:03 +0200
commit091045c7049f7f851bb8166cac5ecbbf828ca6e2 (patch)
treed9a8ab95584c911a175b63eac5c2028ea24774a0 /wsgitools/applications.py
parent2444c54b184a5a9ad89c79d36a456a83e9150d87 (diff)
downloadwsgitools-091045c7049f7f851bb8166cac5ecbbf828ca6e2.tar.gz
applications.StaticContent: fail on bad request
Diffstat (limited to 'wsgitools/applications.py')
-rw-r--r--wsgitools/applications.py12
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 []