def response(self, flow: http.HTTPFlow): for matcher in self.matchermap.values(): if matcher.match(flow): with open(matcher.path, "rt", encoding="utf8") as f: try: txt = f.read() except IOError as e: raise ValueError("can not read file '%s': %s" % (matcher.path, e)) flow.response.status_code = matcher.code flow.response.set_text(txt) flow.is_replay = "response" break
def request(self, f: http.HTTPFlow) -> None: if self.flowmap: rflow = self.next_flow(f) if rflow: assert rflow.response response = rflow.response.copy() if ctx.options.server_replay_refresh: response.refresh() f.response = response f.is_replay = "response" elif ctx.options.server_replay_kill_extra: ctx.log.warn( "server_playback: killed non-replay request {}".format( f.request.url)) f.kill()