mercurial/hgweb/common.py
changeset 31792 161a87ed456e
parent 31444 2daeab02b4b1
child 31793 62f9679df1f2
equal deleted inserted replaced
31791:417363736c11 31792:161a87ed456e
   158         if os.path.exists(path):
   158         if os.path.exists(path):
   159             break
   159             break
   160     try:
   160     try:
   161         os.stat(path)
   161         os.stat(path)
   162         ct = mimetypes.guess_type(path)[0] or "text/plain"
   162         ct = mimetypes.guess_type(path)[0] or "text/plain"
   163         fp = open(path, 'rb')
   163         with open(path, 'rb') as fh:
   164         data = fp.read()
   164             data = fh.read()
   165         fp.close()
   165 
   166         req.respond(HTTP_OK, ct, body=data)
   166         req.respond(HTTP_OK, ct, body=data)
   167     except TypeError:
   167     except TypeError:
   168         raise ErrorResponse(HTTP_SERVER_ERROR, 'illegal filename')
   168         raise ErrorResponse(HTTP_SERVER_ERROR, 'illegal filename')
   169     except OSError as err:
   169     except OSError as err:
   170         if err.errno == errno.ENOENT:
   170         if err.errno == errno.ENOENT: