Here are the examples of the python api aiohttp.web.ContentCoding.gzip taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
3 Examples
3
Example 1
Project: aiohttp Source File: test_web_response.py
@asyncio.coroutine
def test_force_compression_gzip():
req = make_request(
'GET', '/',
headers=CIMultiDict({hdrs.ACCEPT_ENCODING: 'gzip, deflate'}))
resp = StreamResponse()
resp.enable_compression(ContentCoding.gzip)
assert resp.compression
with mock.patch('aiohttp.web_reqrep.ResponseImpl'):
msg = yield from resp.prepare(req)
msg.add_compression_filter.assert_called_with('gzip')
assert 'gzip' == resp.headers.get(hdrs.CONTENT_ENCODING)
3
Example 2
Project: aiohttp Source File: test_web_response.py
@asyncio.coroutine
def test_force_compression_no_accept_gzip():
req = make_request('GET', '/')
resp = StreamResponse()
resp.enable_compression(ContentCoding.gzip)
assert resp.compression
with mock.patch('aiohttp.web_reqrep.ResponseImpl'):
msg = yield from resp.prepare(req)
msg.add_compression_filter.assert_called_with('gzip')
assert 'gzip' == resp.headers.get(hdrs.CONTENT_ENCODING)
3
Example 3
Project: aiohttp Source File: test_web_response.py
@asyncio.coroutine
def test_delete_content_length_if_compression_enabled():
req = make_request('GET', '/')
resp = Response(body=b'answer')
assert 6 == resp.content_length
resp.enable_compression(ContentCoding.gzip)
with mock.patch('aiohttp.web_reqrep.ResponseImpl'):
yield from resp.prepare(req)
assert resp.content_length is None