From 61765b9529381ce33cd73f59494ad21dab73d9b4 Mon Sep 17 00:00:00 2001 From: hunsh Date: Mon, 29 Mar 2021 10:46:53 +0800 Subject: [PATCH 1/2] fix: patch requests prepare headers --- app/main.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/main.py b/app/main.py index aeb5a91..eaa5f94 100644 --- a/app/main.py +++ b/app/main.py @@ -30,6 +30,8 @@ exp3 = re.compile(r'^(?:https?://)?github\.com/.+?/.+?/(?:info|git-).*$') exp4 = re.compile(r'^(?:https?://)?raw\.githubusercontent\.com/.+?/.+?/.+?/.+$') exp5 = re.compile(r'^(?:https?://)?gist\.(?:githubusercontent|github)\.com/.+?/.+?/.+$') +requests.models.PreparedRequest.prepare_headers = lambda _, __: None + @app.route('/') def index(): From f309780131725f37625e4ac09ca3b58005a02862 Mon Sep 17 00:00:00 2001 From: hunsh Date: Mon, 29 Mar 2021 11:12:25 +0800 Subject: [PATCH 2/2] fix: add default encoding --- app/main.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index eaa5f94..4673257 100644 --- a/app/main.py +++ b/app/main.py @@ -30,8 +30,6 @@ exp3 = re.compile(r'^(?:https?://)?github\.com/.+?/.+?/(?:info|git-).*$') exp4 = re.compile(r'^(?:https?://)?raw\.githubusercontent\.com/.+?/.+?/.+?/.+$') exp5 = re.compile(r'^(?:https?://)?gist\.(?:githubusercontent|github)\.com/.+?/.+?/.+$') -requests.models.PreparedRequest.prepare_headers = lambda _, __: None - @app.route('/') def index(): @@ -110,6 +108,7 @@ def proxy(u): r_headers = dict(request.headers) if 'Host' in r_headers: r_headers.pop('Host') + r_headers['Accept-Encoding'] = request.headers.get('Accept-Encoding', 'identity') try: url = u + request.url.replace(request.base_url, '', 1) if url.startswith('https:/') and not url.startswith('https://'):