python-hyper / hyper

HTTP/2 for Python.
http://hyper.rtfd.org/en/latest/
MIT License
1.05k stars 191 forks source link

Something went wrong when https://nghttp2.org/httpbin/headers #379

Closed kmahyyg closed 6 years ago

kmahyyg commented 6 years ago
Python 3.5.4rc1 (default, Jul 25 2017, 08:53:34) 
[GCC 6.4.0 20170704] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from hyper import HTTPConnection
>>> c = HTTPConnection('nghttp2.org')
>>> c.request('GET','/httpbin/headers')
>>> data = c.get_response().read()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/hyper/common/connection.py", line 129, in get_response
    return self._conn.get_response(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/hyper/http11/connection.py", line 221, in get_response
    self
  File "/usr/local/lib/python3.5/dist-packages/hyper/http11/response.py", line 65, in __init__
    assert self._expect_close or self._length is not None or self._chunked
AssertionError
kmahyyg commented 6 years ago
Python 3.5.4rc1 (default, Jul 25 2017, 08:53:34) 
[GCC 6.4.0 20170704] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from hyper import HTTP20Connection
>>> c = HTTP20Connection('nghttp2.org')
>>> c.request('GET','/httpbin/headers')
1
>>> data = c.get_response()
>>> data
<hyper.http20.response.HTTP20Response object at 0x7f7a41891f60>
>>> data.read()
b'{\n  "headers": {\n    "Host": "nghttp2.org",\n    "Via": "2 nghttpx"\n  }\n}\n'

Works correctly with HTTP20Connection