equal
deleted
inserted
replaced
56 XXX iterable content would be better |
56 XXX iterable content would be better |
57 """ |
57 """ |
58 debugmode = self._cw.vreg.config.debugmode |
58 debugmode = self._cw.vreg.config.debugmode |
59 if osp.isdir(path): |
59 if osp.isdir(path): |
60 if self.directory_listing_allowed: |
60 if self.directory_listing_allowed: |
61 return u'' |
61 return b'' |
62 raise Forbidden(path) |
62 raise Forbidden(path) |
63 if not osp.isfile(path): |
63 if not osp.isfile(path): |
64 raise NotFound() |
64 raise NotFound() |
65 if not debugmode: |
65 if not debugmode: |
66 # XXX: Don't provide additional resource information to error responses |
66 # XXX: Don't provide additional resource information to error responses |
77 # os.read after. Improving this specific call will not help |
77 # os.read after. Improving this specific call will not help |
78 # |
78 # |
79 # Real production environment should use dedicated static file serving. |
79 # Real production environment should use dedicated static file serving. |
80 self._cw.set_header('last-modified', generateDateTime(os.stat(path).st_mtime)) |
80 self._cw.set_header('last-modified', generateDateTime(os.stat(path).st_mtime)) |
81 if self._cw.is_client_cache_valid(): |
81 if self._cw.is_client_cache_valid(): |
82 return '' |
82 return b'' |
83 mimetype, encoding = mimetypes.guess_type(path) |
83 mimetype, encoding = mimetypes.guess_type(path) |
84 if mimetype is None: |
84 if mimetype is None: |
85 mimetype = 'application/octet-stream' |
85 mimetype = 'application/octet-stream' |
86 self._cw.set_content_type(mimetype, osp.basename(path), encoding) |
86 self._cw.set_content_type(mimetype, osp.basename(path), encoding) |
87 with open(path, 'rb') as resource: |
87 with open(path, 'rb') as resource: |