-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrequests.py
More file actions
20 lines (14 loc) · 693 Bytes
/
Copy pathrequests.py
File metadata and controls
20 lines (14 loc) · 693 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Due to its mitmproxy dependency, this module can only be imported by files run
# "in" mitm[dump|proxy], e.g. not in the launcher script.
import re
from typing import Optional
from mitmproxy import http
from modules.utilities import equals
CONTENT_TYPE: str = "Content-Type"
REGEX_CHARSET: re.Pattern = re.compile(r"charset=([^;\s]+)")
def inferEncoding(response: http.HTTPResponse) -> Optional[str]:
httpHeaderValue = response.headers.get(CONTENT_TYPE, "").lower()
match = REGEX_CHARSET.search(httpHeaderValue)
return match.group(1) if match else None
def containsQueryParam(param: str, request: http.HTTPRequest) -> bool:
return any(map(equals(param), request.query))