Python3 で tornado を使用して非同期 http リバース プロキシを実装しようとしています。
ハンドラー クラスは次のとおりです。
class RProxyHandler(tornado.web.RequestHandler):
@tornado.web.asynchronous
def get(self):
backend_url = 'http://backend-host/content.html' # temporary fixed
req = tornado.httpclient.HTTPRequest(
url=backend_url)
http_client = tornado.httpclient.AsyncHTTPClient()
http_client.fetch(req, self.backend_callback)
def backend_callback(self, response):
self.write(response.body)
self.finish()
content.html が小さい場合、このコードは正常に機能します。しかし、大きな content.html では、このコードは例外を発生させます:
ERROR:tornado.general:Reached maximum read buffer size
pycurl で大きなコンテンツを処理する方法を見つけました。ただし、Python3 では動作しないようです。
さらに、HTTPRequest に streaming_callback オプションを追加しました。ただし、バックエンド サーバーによってチャンクされた応答が無効になっている場合、コールバックは呼び出されません。
大きなコンテンツをどのように処理できますか?
ありがとう。