当我通过套接字发送 HTTP 响应时,客户端说文件太大。
urllib3.exceptions.ProtocolError: ('Connection aborted.', LineTooLong('got more than 65536 bytes when reading status line'))
这是我在服务器端使用的代码:
class GetHandler(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
response = requests.get('https://example.api.com' + self.path)
self.wfile.write(response.content)
Handler = GetHandler
httpd = socketserver.TCPServer(("", PORT), Handler)
print("serving at port", PORT)
httpd.serve_forever()
如果你想要这里是客户端:
def get(self, url, **kwargs):
kwargs.setdefault('allow_redirects', True)
return self.request('GET', url, **kwargs)
谁能告诉我我做错了什么?