def replay_request(self, f, block=False): """ Returns None if successful, or error message if not. """ if f.live: return "Can't replay live request." if f.intercepted: return "Can't replay while intercepting..." if f.request.raw_content is None: return "Can't replay request with missing content..." if f.request: f.backup() f.request.is_replay = True # TODO: We should be able to remove this. if "Content-Length" in f.request.headers: f.request.headers["Content-Length"] = str(len(f.request.raw_content)) f.response = None f.error = None self.process_new_request(f) rt = http_replay.RequestReplayThread( self.server.config, f, self.event_queue, self.should_exit ) rt.start() # pragma: no cover if block: rt.join()
def replay_request(self, f, block=False): """ Returns an http_replay.RequestReplayThred object. May raise exceptions.ReplayError. """ if f.live: raise exceptions.ReplayError("Can't replay live flow.") if f.intercepted: raise exceptions.ReplayError("Can't replay intercepted flow.") if f.request.raw_content is None: raise exceptions.ReplayError( "Can't replay flow with missing content.") if not f.request: raise exceptions.ReplayError( "Can't replay flow with missing request.") f.backup() f.request.is_replay = True # TODO: We should be able to remove this. if "Content-Length" in f.request.headers: f.request.headers["Content-Length"] = str( len(f.request.raw_content)) f.response = None f.error = None # FIXME: process through all addons? # self.process_new_request(f) rt = http_replay.RequestReplayThread(self.server.config, f, self.event_queue, self.should_exit) rt.start() # pragma: no cover if block: rt.join() return rt
def replay_request(self, f, block=False): """ Replay a HTTP request to receive a new response from the server. Args: f: The flow to replay. block: If True, this function will wait for the replay to finish. This causes a deadlock if activated in the main thread. Returns: The thread object doing the replay. Raises: exceptions.ReplayException, if the flow is in a state where it is ineligible for replay. """ if f.live: raise exceptions.ReplayException("Can't replay live flow.") if f.intercepted: raise exceptions.ReplayException("Can't replay intercepted flow.") if f.request.raw_content is None: raise exceptions.ReplayException( "Can't replay flow with missing content.") if not f.request: raise exceptions.ReplayException( "Can't replay flow with missing request.") f.backup() f.request.is_replay = True f.response = None f.error = None rt = http_replay.RequestReplayThread(self.server.config, f, self.event_queue, self.should_exit) rt.start() # pragma: no cover if block: rt.join() return rt