explicit close file on file:// scheme handler

This commit is contained in:
Daniel Graña 2015-08-11 14:09:49 -03:00
parent c0d0734027
commit d9b4850c44
1 changed files with 2 additions and 1 deletions

View File

@ -10,6 +10,7 @@ class FileDownloadHandler(object):
@defers
def download_request(self, request, spider):
filepath = file_uri_to_path(request.url)
body = open(filepath, 'rb').read()
with open(filepath, 'rb') as fo:
body = fo.read()
respcls = responsetypes.from_args(filename=filepath, body=body)
return respcls(url=request.url, body=body)