(self, spider, request)
return response
Return response if present in cache, or None otherwise.
Return response if present in cache, or None otherwise.
Return response if present in cache or None otherwise .
def retrieve_response(self, spider, request):
        """Return response if present in cache, or None otherwise."""
        metadata = self._read_meta(spider, request)
        if metadata is None:
            return  # not cached
        rpath = self._get_request_path(spider, request)
        with self._open(os.path.join(rpath, 'response_body'), 'rb') as f:
            body = f.read()
        with self._open(os.path.join(rpath, 'response_headers'), 'rb') as f:
            rawheaders = f.read()
        url = metadata.get('response_url')
        status = metadata['status']
        headers = Headers(headers_raw_to_dict(rawheaders))
        respcls = responsetypes.from_args(headers=headers, url=url)
        response = respcls(url=url, headers=headers, status=status, body=body)
        return response
def retrieve_response ( self , spider , request ) : metadata = self . _read_meta ( spider , request ) if metadata is None : return # not cached rpath = self . _get_request_path ( spider , request ) with self . _open ( os . path . join ( rpath , 'response_body' ) , 'rb' ) as f : body = f . read ( ) with self . _open ( os . path . join ( rpath , 'response_headers' ) , 'rb' ) as f : rawheaders = f . read ( ) url = metadata . get ( 'response_url' ) status = metadata [ 'status' ] headers = Headers ( headers_raw_to_dict ( rawheaders ) ) respcls = responsetypes . from_args ( headers = headers , url = url ) response = respcls ( url = url , headers = headers , status = status , body = body ) return response