summaryrefslogtreecommitdiff
path: root/wsgitools/applications.py
diff options
context:
space:
mode:
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 []