tianyun 3 anni fa
parent
commit
ba7dba4b9e
1 ha cambiato i file con 21 aggiunte e 0 eliminazioni
  1. 21 0
      tmp/proxy.py

+ 21 - 0
tmp/proxy.py

@@ -0,0 +1,21 @@
+# -*- coding:utf-8
+import mitmproxy.http
+
+
+class ProxyForward:
+    def request(self, flow: mitmproxy.http.HTTPFlow) -> None:
+        url = flow.request.url
+        if url.startswith("https://eip-portal.qa.mlamp.cn/menura/ui"):
+            url = url.replace("https://eip-portal.qa.mlamp.cn/menura/ui", "http://127.0.0.1:8500/ui")
+            flow.request.url = url
+
+    def response(self, flow: mitmproxy.http.HTTPFlow):
+        flow.response.headers["test"] = "hhhh"
+        flow.response.headers["Content-Security-Policy"] = flow.request.host
+        pass
+
+    def error(self, flow: mitmproxy.http.HTTPFlow):
+        print(flow.error)
+
+
+addons = [ProxyForward()]