Add typing

This commit is contained in:
Midgard 2022-06-08 17:27:50 +02:00
parent 66092b7bc8
commit ca00ad6792
Signed by: midgard
GPG key ID: 511C112F1331BBB4

View file

@ -1,6 +1,6 @@
# Script for mitmproxy, used in ../rundev.sh. Not meant to be run directly.
from mitmproxy import http, ctx
from mitmproxy import http, ctx, flow
# More information about CORS: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
@ -14,11 +14,11 @@ DEFAULT_PORTS = {"http": 80, "https": 443}
def allowed_origin(origin):
return origin if origin in ALLOWED_ORIGINS else ALLOWED_ORIGINS[0]
def response(flow):
def response(flow: flow.Flow):
flow.response.headers["Access-Control-Allow-Origin"] = allowed_origin(flow.request.headers["Origin"])
flow.response.headers["Access-Control-Expose-Headers"] = EXPOSE_HEADERS
def request(flow):
def request(flow: flow.Flow):
original_origin = flow.request.headers["Origin"]
# Spoof Origin, necessary for Mattermost to accept creating a websocket