KeepSafe/aiohttp — pull request #154 by kxepal (2014-09-17 19:01:35+00:00)
Title: Don't decompress responses for HEAD requests

aiohttp causes error on receiving response against HEAD request with CONTENT-ENCODING header.

```
Traceback (most recent call last):
File "/home/kxepal/projects/aiocouchdb/test.py", line 94, in
loop.run_until_complete(go('http://localhost:5984'))
File "/usr/local/opt/virtualenv/aiocouchdb/lib/python3.3/site-packages/asyncio/base_events.py", line 208, in run_until_complete
return future.result()
File "/usr/local/opt/virtualenv/aiocouchdb/lib/python3.3/site-packages/asyncio/futures.py", line 243, in result
raise self._exception
File "/usr/local/opt/virtualenv/aiocouchdb/lib/python3.3/site-packages/asyncio/tasks.py", line 319, in _step
result = coro.send(value)
File "/home/kxepal/projects/aiocouchdb/test.py", line 41, in go
att = yield from doc.att('bar.txt')
File "/home/kxepal/projects/aiocouchdb/aiocouchdb/document.py", line 58, in attachment
yield from resp.read()
File "/home/kxepal/projects/aiocouchdb/aiocouchdb/client.py", line 91, in read
data.extend((yield from self.content.read()))
File "/home/kxepal/projects/aiohttp/aiohttp/streams.py", line 382, in read
return (yield from super().read())
File "/home/kxepal/projects/aiohttp/aiohttp/streams.py", line 393, in read
return (yield from super().read())
File "/home/kxepal/projects/aiohttp/aiohttp/streams.py", line 353, in read
raise self._exception
File "/home/kxepal/projects/aiohttp/aiohttp/parsers.py", line 197, in set_parser
next(p)
File "/home/kxepal/projects/aiohttp/aiohttp/protocol.py", line 307, in __call__
out.feed_eof()
File "/home/kxepal/projects/aiohttp/aiohttp/protocol.py", line 386, in feed_eof
raise errors.IncompleteRead(0)
aiohttp.errors.IncompleteRead: IncompleteRead(0 bytes read)
```

This happens because DeflateBuffer is been used if response is compressed and it tries to decompress the received data on feed_eof. Obliviously, it fails because no data is returned back on HEAD request.