aboutsummaryrefslogtreecommitdiffstats
path: root/examples/simple/modify_form.py
blob: 8742a976fd28b04ad3d5b6c4c1a284967060ac6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
from mitmproxy import http


def request(flow: http.HTTPFlow) -> None:
    if flow.request.urlencoded_form:
        # If there's already a form, one can just add items to the dict:
        flow.request.urlencoded_form["mitmproxy"] = "rocks"
    else:
        # One can also just pass new form data.
        # This sets the proper content type and overrides the body.
        flow.request.urlencoded_form = [
            ("foo", "bar")
        ]