I'm trying to filter PUT method from a cross-origin website that starts with an OPTIONS method then go to PUT method. In mitmweb I can easily see the headers but whenever I am running my code I cannot filter anything and it's showing GET and POST methods and no headers from the PUT method.
Here is my snippet:
from mitmproxy import http, ctx, flow, exceptions, master
import subprocess
import shlex
import time
class PrintPutDetails(master.Master):
def __init__(self, options):
super().__init__(options)
def response(self, flow):
if flow.request.method == "PUT":
print(
f"\n{flow.request.method} {flow.request.url} << HTTP/{flow.response.http_version} {flow.response.status_code} {len(flow.response.content)}")
print("\nRequest Headers:")
for key, value in flow.request.headers.items():
print(f"{key}: {value}")
print("\nResponse Headers:")
for key, value in flow.response.headers.items():
print(f"{key}: {value}")
print("\nResponse Content:")
print(flow.response.content.decode('utf-8'))
time.sleep(10)
mitm_cmd = "mitmdump --mode regular@8083"
mitm_process = subprocess.Popen(shlex.split(mitm_cmd))
I'm using selenium to automate the process click on the button that triggers the OPTIONS then the PUT methods. I want to basically get headers from the PUT method. Any help is appreciated