2020-06-22 23:53:39 +00:00
|
|
|
"""Modify an HTTP form submission."""
|
2017-04-28 21:56:14 +00:00
|
|
|
from mitmproxy import http
|
|
|
|
|
|
|
|
|
|
|
|
def request(flow: http.HTTPFlow) -> None:
|
2016-05-19 05:50:19 +00:00
|
|
|
if flow.request.urlencoded_form:
|
2016-11-21 01:16:20 +00:00
|
|
|
# If there's already a form, one can just add items to the dict:
|
2016-05-19 01:46:42 +00:00
|
|
|
flow.request.urlencoded_form["mitmproxy"] = "rocks"
|
|
|
|
else:
|
2016-11-21 01:16:20 +00:00
|
|
|
# One can also just pass new form data.
|
2016-05-19 01:46:42 +00:00
|
|
|
# This sets the proper content type and overrides the body.
|
2022-04-26 11:53:35 +00:00
|
|
|
flow.request.urlencoded_form = [("foo", "bar")]
|