Skip to content

Commit f0cc2fd

Browse files
authored
Merge pull request #1081 from openatx/avoid_nanohttpd_gzip_leaks
hotfix for nanohttpd gzip leaks
2 parents d8e1623 + ef99837 commit f0cc2fd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

uiautomator2/core.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,16 @@ def _http_request(dev: adbutils.AdbDevice, method: str, path: str, data: Dict[st
101101
fields.append(f"-d '{json.dumps(data)}'")
102102
print(f"# http timeout={timeout}")
103103
print(" ".join(fields))
104-
r = requests.request(method, url, json=data, timeout=timeout)
104+
105+
# set Accept-Encoding to empty to avoid gzip compression
106+
# nanohttpd gzip has resource leaks
107+
# https://github.com/NanoHttpd/nanohttpd/issues/492
108+
# https://blog.csdn.net/fcp12138/article/details/80436644
109+
headers = {
110+
'User-Agent': 'uiautomator2',
111+
'Accept-Encoding': ''
112+
}
113+
r = requests.request(method, url, json=data, timeout=timeout, headers=headers)
105114
r.raise_for_status()
106115
response = HTTPResponse(r.content)
107116
if print_request:

0 commit comments

Comments
 (0)