Modify headers from within mitmproxy

Hi,
I was wondering if it is possible to modify headers from within mitmproxy, using the following examples:

  1. Changing all request headers for GET’s from ‘Accept: text/html’, to ‘Accept: application/json’ ?

  2. Changing a cookie value permanently within the session - i.e. changing a cookie value like ‘UID: 1’ to ‘UID: 0’ for all requests ?

I understand this would be possible calling mitmproxy from a script, but am unsure how to do this within mitmproxy its self. Any help would be appreciated!

Regards,
Anton

Hi,

It looks like https://docs.mitmproxy.org/stable/overview-features/#set-headers should solve your exact problem. You may also want to look into the stickycookie functionality.