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 6b6601b..df304db 100644
--- a/wsgitools/applications.py
+++ b/wsgitools/applications.py
@@ -21,7 +21,7 @@ class StaticContent(object):
@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(object):
"""
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(object):
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(object):
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(object):
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(object):
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]