aboutsummaryrefslogtreecommitdiffstats
path: root/examples/complex/sslstrip.py
diff options
context:
space:
mode:
authorThomas Kriechbaumer <Kriechi@users.noreply.github.com>2020-04-12 22:06:22 +0200
committerGitHub <noreply@github.com>2020-04-12 22:06:22 +0200
commit30645fa1ac6fa828bda390383abee7c04f20206f (patch)
tree10b599dab550e06c6d2d9ffb37dd1a3cf783922a /examples/complex/sslstrip.py
parentce50e8e52dc5316f9be29bc00d0dc72fc2b0af83 (diff)
parent55527c00eb35bf3b07b361363fd8ca2961afc8ba (diff)
downloadmitmproxy-30645fa1ac6fa828bda390383abee7c04f20206f.tar.gz
mitmproxy-30645fa1ac6fa828bda390383abee7c04f20206f.tar.bz2
mitmproxy-30645fa1ac6fa828bda390383abee7c04f20206f.zip
Merge pull request #3921 from Kriechi/example-docs
Example docs
Diffstat (limited to 'examples/complex/sslstrip.py')
-rw-r--r--examples/complex/sslstrip.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/examples/complex/sslstrip.py b/examples/complex/sslstrip.py
index 8b904216..16d9b59a 100644
--- a/examples/complex/sslstrip.py
+++ b/examples/complex/sslstrip.py
@@ -51,9 +51,11 @@ def response(flow: http.HTTPFlow) -> None:
flow.response.headers['Location'] = location.replace('https://', 'http://', 1)
# strip upgrade-insecure-requests in Content-Security-Policy header
- if re.search('upgrade-insecure-requests', flow.response.headers.get('Content-Security-Policy', ''), flags=re.IGNORECASE):
+ csp_header = flow.response.headers.get('Content-Security-Policy', '')
+ if re.search('upgrade-insecure-requests', csp_header, flags=re.IGNORECASE):
csp = flow.response.headers['Content-Security-Policy']
- flow.response.headers['Content-Security-Policy'] = re.sub(r'upgrade-insecure-requests[;\s]*', '', csp, flags=re.IGNORECASE)
+ new_header = re.sub(r'upgrade-insecure-requests[;\s]*', '', csp, flags=re.IGNORECASE)
+ flow.response.headers['Content-Security-Policy'] = new_header
# strip secure flag from 'Set-Cookie' headers
cookies = flow.response.headers.get_all('Set-Cookie')