Skip to content

Commit

Permalink
gzip compression is supported
Browse files Browse the repository at this point in the history
  • Loading branch information
RamanjaneyuluIdavalapati committed Jul 6, 2018
1 parent af646a2 commit a3d21f2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ deploy:
skip_cleanup: true
api_key:
secure: 3wIm6vrNmdIP50NIUtig33S34FonRqxGnRRY55oiMN4BD5xeo2iQb8TmWMswwqVTuO09C3Cd7kBxP5JxBR+dCuVZZRqpL/8E6JUTaGyZcQ/9HgB8FwYXRCj2ASPDHfmjmZ8F3GIX19akJLKiTThB1WU3XidcZ9tZgwvOmf10Jy7IXiddRKwucVVVy608H9hUXPpIVMzqcFfeU2KeXcotU0J2eZyqso/RCPNw4qDZKFvkiKT2MM4B6FgY7WYorNUW1JXdh8dcAV7vb0oNB0iUNLMCpNHFqoyfOHcxKUgP81wMS8TY5wWLuQxUESg1eyo7Q9gwegOseySU1NBjlPyltVVWtulltM2sge0KgVoLgQRia/LeKnCynSi2r8aic1VoMUDEH5ZfWuJJrFHOJyKCNapp3MKK42UXDo28NpdjjUUgJOOukWpXsaVmPhPXpWWQlZM9YMeMPxTUpm3ZACs2WmHssVwO7EaTaJ45ctAf4m0csb7Ri5IyR5iLy9YEX6fuNMoNVCI6lE7ax38pf1mkgamZTJtvEFr+ekKMXq3heVk598rA2P7hzI5Z6Zx7S8GyQz4vveSTk/pY3StX1ScU3ULnLQaEjP1LVI3pu6R5w7PdQ+Ew6fPmU7RpD8rZPKfFoBcby1mf2Mb/HNk8jXPTHTmyTKBB+othHHg4BWM3Kuw=
name: kwikapi.tornado-0.2.6
tag_name: 0.2.6
name: kwikapi.tornado-0.2.7
tag_name: 0.2.7
on:
repo: deep-compute/kwikapi.tornado
- provider: pypi
Expand Down
13 changes: 12 additions & 1 deletion kwikapi/tornado/kwikapi_tornado.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*

import asyncio
import zlib

from tornado.web import RequestHandler as TornadoRequestHandler
from tornado.web import asynchronous
Expand Down Expand Up @@ -45,7 +46,17 @@ def write(self, data, proto, stream=False):
n, t = super().write(data, proto, stream=stream)

if not stream:
self.headers['Content-Length'] = n.value
nbytes = n.value

accept_enc = self._req_hdlr.request.headers['Accept-Encoding']
accept_enc = set([e.strip().lower() for e in accept_enc.split(',') if e.strip()])

if 'gzip' in accept_enc:
self._data = zlib.compress(self._data)
nbytes = len(self._data)
self.headers['Content-Encoding'] = 'gzip'

self.headers['Content-Length'] = nbytes

self._stream = stream

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages

# https://docs.djangoproject.com/en/1.11/intro/reusable-apps/
version = '0.2.6'
version = '0.2.7'
setup(
name="kwikapi-tornado",
version=version,
Expand Down

0 comments on commit a3d21f2

Please sign in to comment.