summaryrefslogtreecommitdiff
path: root/wsgitools/applications.py
diff options
context:
space:
mode:
Diffstat (limited to 'wsgitools/applications.py')
-rw-r--r--wsgitools/applications.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/wsgitools/applications.py b/wsgitools/applications.py
index 8a02fe8..9c6dad8 100644
--- a/wsgitools/applications.py
+++ b/wsgitools/applications.py
@@ -21,7 +21,7 @@ class StaticContent:
@type headers: list
@param headers: is a list of C{(header, value)} pairs being delivered as
HTTP headers
- @type content: basestring
+ @type content: bytes
@param content: contains the data to be delivered to the client. It is
either a string or some kind of iterable yielding strings.
@type anymethod: boolean
@@ -30,12 +30,12 @@ class StaticContent:
"""
assert isinstance(status, str)
assert isinstance(headers, list)
- assert isinstance(content, basestring) or hasattr(content, "__iter__")
+ assert isinstance(content, bytes) or hasattr(content, "__iter__")
self.status = status
self.headers = headers
self.anymethod = anymethod
length = -1
- if isinstance(content, basestring):
+ if isinstance(content, bytes):
self.content = [content]
length = len(content)
else:
@@ -50,7 +50,7 @@ class StaticContent:
assert isinstance(environ, dict)
if environ["REQUEST_METHOD"].upper() not in ["GET", "HEAD"] and \
not self.anymethod:
- resp = "Request method not implemented"
+ resp = b"Request method not implemented"
start_response("501 Not Implemented",
[("Content-length", str(len(resp)))])
return [resp]
@@ -102,7 +102,7 @@ class StaticFile:
assert isinstance(environ, dict)
if environ["REQUEST_METHOD"].upper() not in ["GET", "HEAD"]:
- resp = "Request method not implemented"
+ resp = b"Request method not implemented"
start_response("501 Not Implemented",
[("Content-length", str(len(resp)))])
return [resp]
@@ -112,7 +112,7 @@ class StaticFile:
try:
if isinstance(self.filelike, basestring):
# raises IOError
- stream = file(self.filelike)
+ stream = open(self.filelike, "rb")
size = os.path.getsize(self.filelike)
else:
stream = self.filelike
@@ -121,7 +121,7 @@ class StaticFile:
size = stream.tell()
stream.seek(0)
except IOError:
- resp = "File not found"
+ resp = b"File not found"
start_response("404 File not found",
[("Content-length", str(len(resp)))])
return [resp]