We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
现在使用同样的nginx配置,clone时不会提示502
nginx反代配置如下
location / { proxy_pass http://127.0.0.1:59740/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Range $http_range; proxy_set_header If-Range $http_if_range; proxy_set_header Connection ''; }
chatgpt修改main.py之后测试正常
from flask import make_response # 代理函数中的修改部分 def proxy(u, allow_redirects=False): headers = {} r_headers = dict(request.headers) if 'Host' in r_headers: r_headers.pop('Host') try: url = u + request.url.replace(request.base_url, '', 1) if url.startswith('https:/') and not url.startswith('https://'): url = 'https://' + url[7:] r = requests.request(method=request.method, url=url, data=request.data, headers=r_headers, stream=True, allow_redirects=allow_redirects) headers = dict(r.headers) if 'Content-length' in r.headers and int(r.headers['Content-length']) > size_limit: return redirect(u + request.url.replace(request.base_url, '', 1)) def generate(): for chunk in iter_content(r, chunk_size=CHUNK_SIZE): yield chunk response = Response(generate(), status=r.status_code) # 移除可能导致问题的头部 headers.pop('Transfer-Encoding', None) # 添加头部到响应中 for key, value in headers.items(): response.headers[key] = value if 'Location' in headers: _location = headers.get('Location') if check_url(_location): response.headers['Location'] = '/' + _location else: # 这是一个递归代理调用,考虑到可能的循环重定向,应当谨慎使用 return proxy(_location, True) return response except Exception as e: return Response(f'server error {str(e)}', status=500) # Flask 应用的其余部分保持不变
The text was updated successfully, but these errors were encountered:
可以提交一个pr。
Sorry, something went wrong.
No branches or pull requests
现在使用同样的nginx配置,clone时不会提示502
nginx反代配置如下
chatgpt修改main.py之后测试正常
The text was updated successfully, but these errors were encountered: