From ca00ad6792649e1146c011f4bdf83669c2a45e14 Mon Sep 17 00:00:00 2001 From: Midgard Date: Wed, 8 Jun 2022 17:27:50 +0200 Subject: [PATCH] Add typing --- etc/mitm_cors.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/etc/mitm_cors.py b/etc/mitm_cors.py index f80761d..c62f21d 100644 --- a/etc/mitm_cors.py +++ b/etc/mitm_cors.py @@ -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