equal
deleted
inserted
replaced
217 mimetypes.guess_type(pycompat.fsdecode(fpath))[0] or r"text/plain" |
217 mimetypes.guess_type(pycompat.fsdecode(fpath))[0] or r"text/plain" |
218 ) |
218 ) |
219 path = os.path.join(directory, fpath) |
219 path = os.path.join(directory, fpath) |
220 try: |
220 try: |
221 os.stat(path) |
221 os.stat(path) |
222 with open(path, 'rb') as fh: |
222 data = util.readfile(path) |
223 data = fh.read() |
|
224 except TypeError: |
223 except TypeError: |
225 raise ErrorResponse(HTTP_SERVER_ERROR, b'illegal filename') |
224 raise ErrorResponse(HTTP_SERVER_ERROR, b'illegal filename') |
226 except OSError as err: |
225 except OSError as err: |
227 if err.errno == errno.ENOENT: |
226 if err.errno == errno.ENOENT: |
228 raise ErrorResponse(HTTP_NOT_FOUND) |
227 raise ErrorResponse(HTTP_NOT_FOUND) |