def dump(self, response):
        # This function takes in a HTTPResponse object and dumps the request
        # and response data. It also creates a .rd file with same file name
        # This is used by transaction logger
        try:
            response_body = unicode(self.request.response_buffer, "utf-8")
            binary_response = False
        except __HOLE__:
            response_body = base64.b64encode(self.request.response_buffer)
            binary_response = True
        cache_dict = {
                            'request_method':self.request.method,
                            'request_url':self.request.url,
                            'request_version':self.request.version,
                            'request_headers':dict(self.request.headers),
                            'request_body':self.request.body,
                            'request_time':response.request_time,
                            'request_local_timestamp':self.request.local_timestamp.isoformat(),
                            'response_code':response.code,
                            'response_headers':dict(response.headers),
                            'response_body':response_body,
                            'response_cookies':response.headers.get_list("Set-Cookie"),
                            'binary_response':binary_response
                     }
        with open(self.file_path, 'w') as outfile:
            json.dump(cache_dict, outfile)

        # This approach can be used as an alternative for object sharing
        # This creates a file with hash as name and .rd as extension
        open(self.file_path + '.rd', 'w').close()
        self.file_lock.release()
dataset/ETHPy150Open owtf/owtf/framework/http/proxy/cache_handler.py/CacheHandler.dump