summaryrefslogtreecommitdiff
path: root/wsgitools/applications.py
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2015-04-18 20:38:13 +0200
committerHelmut Grohne <helmut@subdivi.de>2015-04-18 20:38:13 +0200
commit828d8f22ee3e785692d019ed02c4f7874792a8e9 (patch)
treeb14886c4cca174d993ee7e882ea4f4ba3eabb55e /wsgitools/applications.py
parent42f5ccf09799d3e475eb996b023a0daabae49cdb (diff)
parentc1ba0c783fc59dc8d00b9b8aed7250569bcc14d4 (diff)
downloadwsgitools-828d8f22ee3e785692d019ed02c4f7874792a8e9.tar.gz
Merge branch py3k
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]