def resp(self): f = self.req() headers = flow.ODictCaseless() headers["header_response"] = ["svalue"] f.response = http.HTTPResponse((1, 1), 200, "OK", headers, "content_response", None, None) return f
def resp(self): f = self.req() headers = Headers([["header_response", "svalue"]]) f.response = http.HTTPResponse((1, 1), 200, "OK", headers, "content_response", None, None) return f
def tresp(content="message"): """ @return: libmproxy.protocol.http.HTTPResponse """ headers = odict.ODictCaseless() headers["header_response"] = ["svalue"] resp = http.HTTPResponse((1, 1), 200, "OK", headers, content, time(), time()) return resp
def tresp(req=None, content="message"): if not req: req = treq() f = req.flow headers = flow.ODictCaseless() headers["header_response"] = ["svalue"] cert = certutils.SSLCert.from_der( file(test_data.path("data/dercert"), "rb").read()) f.server_conn = ServerConnection._from_state( dict(address=dict(address=("address", 22), use_ipv6=True), source_address=None, cert=cert.to_pem())) f.response = http.HTTPResponse((1, 1), 200, "OK", headers, content, time(), time()) f.response.reply = controller.DummyReply() return f.response
def request(context, flow): if not flow.request.host == "opsen-static.dolphin-browser.com" \ or not flow.request.path.endswith(".dwp"): return # Build response # response = http.HTTPResponse( [1, 1], 200, "OK", odict.ODictCaseless([["Content-Type", "application/zip"]]), "yo!") # Inject theme # try: with open("Red_roof.dwp", "r") as f: modified = f.read() response.content = modified response.headers["Content-Length"] = [len(modified)] f.close() except IOError as e: raise e # Return response # flow.reply(response)