From f292a385a66039dfdd9ddadae667a192197e6ca5 Mon Sep 17 00:00:00 2001 From: hunshnet <337490703@qq.com> Date: Sat, 9 May 2020 16:00:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dpython=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E6=97=A0=E6=B3=95clone=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/main.py b/app/main.py index e283ebf..8511667 100644 --- a/app/main.py +++ b/app/main.py @@ -29,7 +29,7 @@ def index(): return index_html -@app.route('/') +@app.route('/', methods=['GET', 'POST']) def proxy(u): u = u if u.startswith('http') else 'https://' + u u = u.replace(':/g', '://g', 1) # uwsgi会将//传递为/ @@ -50,12 +50,16 @@ def proxy(u): if i in request.headers: r_headers[i] = request.headers.get(i) try: - r = requests.get(u + request.url.replace(request.base_url, ''), headers=r_headers, stream=True) + r = requests.request(method=request.method, url=u + request.url.replace(request.base_url, ''), data=request.data, headers=r_headers, stream=True) for i in ['Content-Type']: if i in r.headers: headers[i] = r.headers.get(i) if r.status_code == 200: headers = dict(r.headers) + try: + headers.pop('Transfer-Encoding') + except: + pass def generate(): for chunk in r.iter_content(chunk_size=CHUNK_SIZE):