HTTP/2 Client for Python
.. image:: https://raw.github.com/Lukasa/hyper/development/docs/source/images/hyper.png
.. image:: https://travis-ci.org/Lukasa/hyper.png?branch=master :target: https://travis-ci.org/Lukasa/hyper
HTTP is changing under our feet. HTTP/1.1, our old friend, is being supplemented by the brand new HTTP/2 standard. HTTP/2 provides many benefits: improved speed, lower bandwidth usage, better connection management, and more.
hyper
provides these benefits to your Python code. How? Like this::
from hyper import HTTPConnection
conn = HTTPConnection('http2bin.org:443')
conn.request('GET', '/get')
resp = conn.get_response()
print(resp.read())
Simple.
Please be warned: hyper
is in a very early alpha. You will encounter bugs
when using it. In addition, there are very many rough edges. With that said,
please try it out in your applications: I need your feedback to fix the bugs
and file down the rough edges.
hyper
supports the final draft of the HTTP/2 specification: additionally,
it provides support for drafts 14, 15, and 16 of the HTTP/2 specification. It
also supports the final draft of the HPACK specification.
hyper
is intended to be a drop-in replacement for http.client
, with a
similar API. However, hyper
intentionally does not name its classes the
same way http.client
does. This is because most servers do not support
HTTP/2 at this time: I don't want you accidentally using hyper
when you
wanted http.client
.
Looking to learn more? Documentation for hyper
can be found on Read the Docs
_.
.. _Read the Docs: http://hyper.readthedocs.io/en/latest/
hyper
welcomes contributions from anyone! Unlike many other projects we are
happy to accept cosmetic contributions and small contributions, in addition to
large feature requests and changes.
Before you contribute (either by opening an issue or filing a pull request),
please read the contribution guidelines
_.
.. _read the contribution guidelines: http://hyper.readthedocs.org/en/development/contributing.html
hyper
is made available under the MIT License. For more details, see the
LICENSE
file in the repository.
hyper
is maintained by Cory Benfield, with contributions from others. For
more details about the contributors, please see CONTRIBUTORS.rst
.
Major Changes
ping
method, allowing the user to use the HTTP/2 PING
frame
to check connection liveness before, instead of, or between issuing requests.Bugfixes
Bugfixes
Bugfixes
fileno()
on the compatibility SSLSocket
object
actually work correctly. Thanks to @benlast!Stream
class. Thanks to
@fredthomsen!Major Changes
HTTP20Connection
object is now thread-safe, so long as stream IDs are
used on all method calls.API Changes
request
.HTTP20Connection
now has a force_proto
keyword argument to allow the
HTTP20Connection
to ignore the NPN/ALPN result.--h2
CLI flag now ignores the result of NPN/ALPN negotiation when
hitting HTTPS URLs.Bugfixes
HTTP2-Settings
header.Feature Enhancement
Bugfixes
https
-schemed URL.--h2
flag to the Hyper CLI tool, which allows straight HTTP/2
in plaintext, rather than attempting to upgrade from HTTP/1.1.get_response
.Software Updates
New Features
Issue #28
_)HTTP11Connection
and HTTPConnection
objects are now both context
managers.Issue #31
_)Issue #8
_)Issue #119
_)Issue #15
_)Structural Changes
Bugfixes
.. _Issue #8: https://github.com/Lukasa/hyper/issues/8 .. _Issue #15: https://github.com/Lukasa/hyper/issues/15 .. _Issue #28: https://github.com/Lukasa/hyper/issues/28 .. _Issue #31: https://github.com/Lukasa/hyper/issues/31 .. _Issue #119: https://github.com/Lukasa/hyper/issues/119
Bugfixes
ImportError
. (Issue #114
_).. _Issue #114: https://github.com/Lukasa/hyper/issues/114
New Features
Issue #75
_)HTTPHeaderMap
data structure that provides dictionary
style lookups while retaining all the semantic information of HTTP headers.Major Changes
Various changes in the HTTP/2 APIs:
getheader
, getheaders
, gettrailer
, and gettrailers
methods on the response object have been removed, replaced instead with
simple .headers
and .trailers
properties that contain
HTTPHeaderMap
structures.iter_chunked()
method was added to response objects that allows
iterating over data in units of individual data frames.getresponse()
to get_response()
, because
getresponse()
was a terrible name forced upon me by httplib... _Issue #75: https://github.com/Lukasa/hyper/issues/75
Bugfixes
Issue #110
_).. _Issue #110: https://github.com/Lukasa/hyper/issues/110
New Features
hyper
command-line client that supports making HTTP/2
requests directly from the command-line.Major Changes
Minor Changes
Major Changes
Minor Changes
Connection
header if it's given to us, as that header
is not valid in HTTP/2.Bugfixes
Minor Changes
Bugfixes
AttributeError
being raised when a PING frame was received, thanks
to @t2y. (Issue #79
_)Issue #80
_).. _Issue #79: https://github.com/Lukasa/hyper/issues/79 .. _Issue #80: https://github.com/Lukasa/hyper/issues/80
Regressions and Known Bugs
ssl
module. PyOpenSSL has been identified as a
replacement, but until NPN support is merged it cannot be used. Python 3.3
support will be re-added when a suitable release of PyOpenSSL is shipped.For more information on these regressions, please see Issue #37
_.
Major Changes
Issue #40
_)Issue #56
_)nghttp2
_ is present, use its HPACK encoder for improved speed and
compression efficiency. (Issue #60
_)HTTP20Response.gettrailer()
and HTTP20Response.gettrailers()
,
supporting downloading and examining HTTP trailers. (Discussed in part in
Issue #71
_.)Bugfixes
HTTP20Response
objects are context managers. (Issue #24
_)Issue #26
_)Issue #39
_)Issue #41
_ and Issue #52
_)Issue #27
_)Issue #48
_)Issue #46
_)Issue #50
_).. _Issue #24: https://github.com/Lukasa/hyper/issues/24 .. _Issue #26: https://github.com/Lukasa/hyper/issues/26 .. _Issue #27: https://github.com/Lukasa/hyper/issues/27 .. _Issue #33: https://github.com/Lukasa/hyper/issues/33 .. _Issue #37: https://github.com/Lukasa/hyper/issues/37 .. _Issue #39: https://github.com/Lukasa/hyper/issues/39 .. _Issue #40: https://github.com/Lukasa/hyper/issues/40 .. _Issue #41: https://github.com/Lukasa/hyper/issues/41 .. _Issue #46: https://github.com/Lukasa/hyper/issues/46 .. _Issue #48: https://github.com/Lukasa/hyper/issues/48 .. _Issue #50: https://github.com/Lukasa/hyper/issues/50 .. _Issue #52: https://github.com/Lukasa/hyper/issues/52 .. _Issue #56: https://github.com/Lukasa/hyper/issues/56 .. _Issue #60: https://github.com/Lukasa/hyper/issues/60 .. _Issue #71: https://github.com/Lukasa/hyper/issues/71 .. _nghttp2: https://nghttp2.org/
HPACKDecodingError
when we're unable to validly map a
Huffman-encoded string.Issue #9
_)Issue #13
_)HTTP20Adapter
correctly reuses connections.Issue #14
_).. _Issue #9: https://github.com/Lukasa/hyper/issues/9 .. _Issue #13: https://github.com/Lukasa/hyper/issues/13 .. _Issue #14: https://github.com/Lukasa/hyper/issues/14
Issue #12
_)Issue #16
_)HTTP20Connection
objects are now context managers. (Issue #13
_)Issue #20
_)Issue #19
_)Issue #22
_).. _Issue #12: https://github.com/Lukasa/hyper/issues/12 .. _Issue #16: https://github.com/Lukasa/hyper/issues/16 .. _Issue #13: https://github.com/Lukasa/hyper/issues/13 .. _Issue #20: https://github.com/Lukasa/hyper/issues/20 .. _Issue #19: https://github.com/Lukasa/hyper/issues/19 .. _Issue #22: https://github.com/Lukasa/hyper/issues/22