From 2f44b26b4cd014e03dd62a125d79af9b81663a93 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Wed, 3 Sep 2014 23:44:54 +0200 Subject: improve HTTPRequest syntax --- examples/modify_form.py | 4 ++-- examples/modify_querystring.py | 4 ++-- examples/redirect_requests.py | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'examples') diff --git a/examples/modify_form.py b/examples/modify_form.py index 2d839aed..cb12ee0f 100644 --- a/examples/modify_form.py +++ b/examples/modify_form.py @@ -1,8 +1,8 @@ def request(context, flow): if "application/x-www-form-urlencoded" in flow.request.headers["content-type"]: - frm = flow.request.get_form_urlencoded() + frm = flow.request.form_urlencoded frm["mitmproxy"] = ["rocks"] - flow.request.set_form_urlencoded(frm) + flow.request.form_urlencoded = frm diff --git a/examples/modify_querystring.py b/examples/modify_querystring.py index b1abcc1e..7e3a068a 100644 --- a/examples/modify_querystring.py +++ b/examples/modify_querystring.py @@ -1,7 +1,7 @@ def request(context, flow): - q = flow.request.get_query() + q = flow.request.query if q: q["mitmproxy"] = ["rocks"] - flow.request.set_query(q) + flow.request.query = q diff --git a/examples/redirect_requests.py b/examples/redirect_requests.py index a9a7e795..b57df2b2 100644 --- a/examples/redirect_requests.py +++ b/examples/redirect_requests.py @@ -7,12 +7,12 @@ This example shows two ways to redirect flows to other destinations. def request(context, flow): - if flow.request.get_host(hostheader=True).endswith("example.com"): + if flow.request.pretty_host(hostheader=True).endswith("example.com"): resp = HTTPResponse( [1, 1], 200, "OK", ODictCaseless([["Content-Type", "text/html"]]), "helloworld") flow.request.reply(resp) - if flow.request.get_host(hostheader=True).endswith("example.org"): + if flow.request.pretty_host(hostheader=True).endswith("example.org"): flow.request.host = "mitmproxy.org" - flow.request.headers["Host"] = ["mitmproxy.org"] + flow.request.update_host_header() -- cgit v1.2.3