Ярик Макаров
2018-06-28 12:45:39 UTC
Hi, I`m trying to save gzip response from clickhouse http api.
Does Tornado automatically decompress gzip-encoded responses like, for
example, requests python module?
If so, how can I disable it and get raw data?
Code example:
class GetLogHandler(tornado.web.RequestHandler):
@tornado.gen.coroutine
def get(self):
self.set_header('Accept-Encoding', 'gzip')
self.set_header('content-Disposition', 'attachment;
filename=test.gz')
self.flush()
query = "select * from test_table"
select_query = urllib.quote(query)
url = "http://localhost:8123/?enable_http_compression=1&query=%s" %
select_query
yield AsyncHTTPClient().fetch(url,
streaming_callback=self.streaming_callback, decompress_response=False)
self.finish()
def streaming_callback(self, chunk):
self.write(chunk)
self.flush()
class Application(tornado.web.Application):
def __init__(self):
handlers = [
(r"/", GetLogHandler)
]
tornado.web.Application.__init__(self, handlers)
Thanks,
Yaroslav.
Does Tornado automatically decompress gzip-encoded responses like, for
example, requests python module?
If so, how can I disable it and get raw data?
Code example:
class GetLogHandler(tornado.web.RequestHandler):
@tornado.gen.coroutine
def get(self):
self.set_header('Accept-Encoding', 'gzip')
self.set_header('content-Disposition', 'attachment;
filename=test.gz')
self.flush()
query = "select * from test_table"
select_query = urllib.quote(query)
url = "http://localhost:8123/?enable_http_compression=1&query=%s" %
select_query
yield AsyncHTTPClient().fetch(url,
streaming_callback=self.streaming_callback, decompress_response=False)
self.finish()
def streaming_callback(self, chunk):
self.write(chunk)
self.flush()
class Application(tornado.web.Application):
def __init__(self):
handlers = [
(r"/", GetLogHandler)
]
tornado.web.Application.__init__(self, handlers)
Thanks,
Yaroslav.
--
You received this message because you are subscribed to the Google Groups "Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-tornado+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-tornado+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.