Add typing
This commit is contained in:
parent
66092b7bc8
commit
ca00ad6792
1 changed files with 3 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
||||||
# Script for mitmproxy, used in ../rundev.sh. Not meant to be run directly.
|
# 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
|
# 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):
|
def allowed_origin(origin):
|
||||||
return origin if origin in ALLOWED_ORIGINS else ALLOWED_ORIGINS[0]
|
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-Allow-Origin"] = allowed_origin(flow.request.headers["Origin"])
|
||||||
flow.response.headers["Access-Control-Expose-Headers"] = EXPOSE_HEADERS
|
flow.response.headers["Access-Control-Expose-Headers"] = EXPOSE_HEADERS
|
||||||
|
|
||||||
def request(flow):
|
def request(flow: flow.Flow):
|
||||||
original_origin = flow.request.headers["Origin"]
|
original_origin = flow.request.headers["Origin"]
|
||||||
|
|
||||||
# Spoof Origin, necessary for Mattermost to accept creating a websocket
|
# Spoof Origin, necessary for Mattermost to accept creating a websocket
|
||||||
|
|
Loading…
Reference in a new issue