Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty body handled as error (204 No Content) #758

Closed
zloidemon opened this issue Feb 2, 2016 · 5 comments
Closed

Empty body handled as error (204 No Content) #758

zloidemon opened this issue Feb 2, 2016 · 5 comments
Labels

Comments

@zloidemon
Copy link

An empty body handled as error. Although it isn't error. I see aiohttp code, it always trying to decompress empty data and raised.

Traceback (most recent call last):
  File "example.py", line 22, in <module>
    fetch_page(rh))
  File "/usr/local/lib/python3.5/asyncio/base_events.py", line 342, in run_until_complete
    return future.result()
  File "/usr/local/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/usr/local/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(value)
  File "example.py", line 8, in fetch_page
    print(await Bucket(client, 'ololo').delete('XXXX'))
  File "/usr/home/vg/Develop/aiohttp_riak/aiohttp_riak/Bucket.py", line 100, in delete
    return False
  File "/usr/home/vg/Develop/aiohttp_riak/.venv/lib/python3.5/site-packages/aiohttp/client.py", line 523, in __aexit__
    yield from self._resp.release()
  File "/usr/home/vg/Develop/aiohttp_riak/.venv/lib/python3.5/site-packages/aiohttp/client_reqrep.py", line 656, in release
    chunk = yield from content.readany()
  File "/usr/home/vg/Develop/aiohttp_riak/.venv/lib/python3.5/site-packages/aiohttp/streams.py", line 472, in wrapper
    result = yield from func(self, *args, **kw)
  File "/usr/home/vg/Develop/aiohttp_riak/.venv/lib/python3.5/site-packages/aiohttp/streams.py", line 535, in readany
    return (yield from super().readany())
  File "/usr/home/vg/Develop/aiohttp_riak/.venv/lib/python3.5/site-packages/aiohttp/streams.py", line 265, in readany
    raise self._exception
  File "/usr/home/vg/Develop/aiohttp_riak/.venv/lib/python3.5/site-packages/aiohttp/parsers.py", line 189, in set_parser
    next(p)
  File "/usr/home/vg/Develop/aiohttp_riak/.venv/lib/python3.5/site-packages/aiohttp/protocol.py", line 313, in __call__
    out.feed_eof()
  File "/usr/home/vg/Develop/aiohttp_riak/.venv/lib/python3.5/site-packages/aiohttp/protocol.py", line 387, in feed_eof
    raise errors.ContentEncodingError('deflate')
aiohttp.errors.ContentEncodingError: 400, message='deflate'
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x806696470>
curl -XDELETE -v localhost:8098/buckets/ololo/keys/XXXX                                                                              
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8098 (#0)
> DELETE /buckets/ololo/keys/XXXX HTTP/1.1
> Host: localhost:8098
> User-Agent: curl/7.45.0
> Accept: */*
> 
< HTTP/1.1 204 No Content
< Vary: Accept-Encoding
< Server: MochiWeb/1.1 WebMachine/1.10.0 (never breaks eye contact)
< Date: Tue, 02 Feb 2016 09:39:46 GMT
< Content-Type: application/json
< Content-Length: 0
< 
* Connection #0 to host localhost left intact
12:43:49.902869 IP localhost.8098 > localhost.49355: Flags [P.], seq 400:425, ack 244, win 128, options [nop,nop,TS val 586110440 ecr 1045355615], length 25
E..Me.@[email protected]..<._.).....A.....
".U.>N._..................I*.....
12:43:49.902878 IP localhost.49355 > localhost.8098: Flags [.], ack 425, win 1269, options [nop,nop,TS val 1045355616 ecr 586110440], length 0
E..4e.@.@................_.)Z..U.....(.....
>N.`".U.
12:43:49.918847 IP localhost.49355 > localhost.8098: Flags [P.], seq 244:437, ack 425, win 1275, options [nop,nop,TS val 1045355632 ecr 586110440], length 193
E...e.@.@................_.)Z..U...........
>N.p".U.DELETE /buckets/ololo/keys/XXXX HTTP/1.1
ACCEPT: */*
ACCEPT-ENCODING: gzip, deflate
HOST: 127.0.0.1:8098
USER-AGENT: Python/3.5 aiohttp/0.20.2
CONTENT-LENGTH: 0
CONNECTION: keep-alive


12:43:49.921062 IP localhost.8098 > localhost.49355: Flags [P.], seq 425:654, ack 437, win 128, options [nop,nop,TS val 586110459 ecr 1045355632], length 229
......@[email protected]._.......
".U.>N.pHTTP/1.1 204 No Content
Vary: Accept-Encoding
Server: MochiWeb/1.1 WebMachine/1.10.0 (never breaks eye contact)
Date: Tue, 02 Feb 2016 09:43:49 GMT
Content-Type: application/json
Content-Length: 0
Content-Encoding: gzip


12:43:49.939182 IP localhost.49355 > localhost.8098: Flags [F.], seq 437, ack 654, win 1275, options [nop,nop,TS val 1045355653 ecr 586110459], length 0
E..4e.@.@................_..Z..:.....(.....
>N..".U.
12:43:49.939216 IP localhost.8098 > localhost.49355: Flags [.], ack 438, win 128, options [nop,nop,TS val 586110477 ecr 1045355653], length 0
E..4e.@[email protected]..:._.......(.....
>N..
12:43:49.939352 IP localhost.8098 > localhost.49355: Flags [F.], seq 654, ack 438, win 128, options [nop,nop,TS val 586110477 ecr 1045355653], length 0
E..4e.@[email protected]..:._.......(.....
>N..
12:43:49.939369 IP localhost.49355 > localhost.8098: Flags [.], ack 655, win 1275, options [nop,nop,TS val 1045355653 ecr 586110477], length 0
E..4e.@.@................_..Z..;.....(.....
>N..".V
@zloidemon zloidemon changed the title Empty body handled as error Empty body handled as error (204 No Content) Feb 2, 2016
@asvetlov
Copy link
Member

asvetlov commented Feb 3, 2016

Would you provide a Pull Request with fix?

@rgacote
Copy link

rgacote commented Feb 27, 2016

Just ran into this issue and have some additional information.
Was able to work around the issue by setting the Accept-Encoding header to either identity or application/json (obviously, I was working with a JSON API).
With either Accept-Encoding selected, you get the 204 status code but avoid the deflate exception that is otherwise raised.

@asvetlov
Copy link
Member

I have a fix.
@zloidemon @rgacote would you test and review it?

asvetlov added a commit that referenced this issue Feb 28, 2016
Fix #758: Handle empty body with gzipped encoding
@rgacote
Copy link

rgacote commented Feb 29, 2016

That works nicely. Thanks.
—Ray

On Sun, Feb 28, 2016 at 4:13 PM, Andrew Svetlov [email protected]
wrote:

I have a fix.
@zloidemon https:/zloidemon @rgacote
https:/rgacote would you test and review it?


Reply to this email directly or view it on GitHub
#758 (comment).

Raymond Cote, President
voice: +1.603.924.6079 email: [email protected] skype:
ray.cote

@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants