fix serving binary files on windows

This commit is contained in:
Damien Churchill 2009-04-20 20:26:03 +00:00
parent 2f44899521
commit 503169ce76
1 changed files with 5 additions and 3 deletions

View File

@ -203,13 +203,15 @@ class LookupResource(resource.Resource, component.Component):
request.path = path
return self
def render(self, request):
def render(self, request):
log.debug("Requested path: '%s'", request.path)
for lookup in self.directories:
if request.path in os.listdir(lookup):
path = os.path.join(lookup, request.path)
path = os.path.join(lookup, request.path)
log.debug("Serving path: '%s'", path)
mime_type = mimetypes.guess_type(path)
request.setHeader("content-type", mime_type[0])
return open(path).read()
return open(path, "rb").read()
request.setResponseCode(http.NOT_FOUND)
return "<h1>404 - Not Found</h1>"