Name | urllib3-ext-hface JSON |
Version |
0.3.4
JSON |
| download |
home_page | |
Summary | urllib3 extension to support HTTP/1.1, HTTP/2 and HTTP/3 independently of Python httplib |
upload_time | 2023-06-16 06:43:59 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.7 |
license | Apache-2.0 |
keywords |
extension
h11
h2
h3
quic
urllib3
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
===================================================
urllib3 extension: hface
===================================================
PyPI_
This project is a fork of the akamai/hface project but highly slimmed.
The purpose of that project is to enable basic support for HTTP/1.1, HTTP/2 and HTTP/3 in urllib3.
* HTTP/1.1, HTTP/2, and HTTP/3 support through respectively h11, h2 and aioquic
* Sans-IO_ core with pluggable protocol implementations
* Layered design with well-defined APIs
* Client-oriented only
.. _PyPI: https://pypi.org/project/urllib3-ext-hface
.. _Sans-IO: https://sans-io.readthedocs.io/
Documentation
-------------
This library is pretty straight forward and is very easy to understand.
.. code-block:: python
from urllib3_ext_hface import HTTPProtocolFactory, HTTP1Protocol, HTTP2Protocol, HTTP3Protocol
protocol = HTTPProtocolFactory.new(HTTP2Protocol)
# ...
protocol.bytes_to_send() # Out to your network I/O implementation
# ...
protocol.bytes_received() # Whatever comes from your network I/O implementation
# ...
protocol.next_event() # Output the next event in order that the state-machine generated
Here ``protocol`` is either of type ``HTTPOverQUICProtocol`` or ``HTTPOverTCPProtocol``, depending
on the foremost, you will either be on a DGRAM (UDP) or STREAM (TCP) socket.
Find just bellow a somewhat stupid example that can help you get started.
.. code-block:: python
from urllib3_ext_hface import HTTPProtocolFactory, HTTP1Protocol, HTTP2Protocol, HTTP3Protocol
import ssl
import socket
import certifi
RECV_LENGTH = 4096
if __name__ == "__main__":
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
ctx.set_alpn_protocols(["h2"])
ctx.load_default_certs()
ctx.load_verify_locations(certifi.where())
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock = ctx.wrap_socket(sock, server_hostname="httpbin.org")
sock.connect(("httpbin.org", 443))
sock.settimeout(3)
protocol = HTTPProtocolFactory.new(HTTP2Protocol)
# Start HTTP2*PRI
while True:
data_out = protocol.bytes_to_send()
if not data_out:
break
sock.sendall(data_out)
protocol.bytes_received(
sock.recv(RECV_LENGTH)
)
stream_id = protocol.get_available_stream_id()
protocol.submit_headers(
stream_id,
[
(b":authority", b"httpbin.org"),
(b":scheme", b"https"),
(b":path", b"/headers"),
(b":method", b"GET"),
(b"User-Agent", b"Awesome Sans-IO!")
],
True
)
sock.sendall(
protocol.bytes_to_send()
)
while True:
try:
protocol.bytes_received(
sock.recv(RECV_LENGTH)
)
except TimeoutError:
protocol.connection_lost()
event = protocol.next_event()
if hasattr(event, "data"):
print(event.data)
print(event)
if hasattr(event, "end_stream") and event.end_stream is True:
break
protocol.submit_close()
sock.sendall(protocol.bytes_to_send())
sock.close()
License
-------
::
Copyright 2022 Akamai Technologies, Inc
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Raw data
{
"_id": null,
"home_page": "",
"name": "urllib3-ext-hface",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "\"Ahmed R. TAHRI\" <ahmed.tahri@cloudnursery.dev>",
"keywords": "extension,h11,h2,h3,quic,urllib3",
"author": "",
"author_email": "Miloslav Pojman <mpojman@akamai.com>",
"download_url": "https://files.pythonhosted.org/packages/8b/cc/0949733abbb6d329e78754877a2cea22435bb21616a843ca11a535324780/urllib3_ext_hface-0.3.4.tar.gz",
"platform": null,
"description": "\n===================================================\nurllib3 extension: hface\n===================================================\n\nPyPI_\n\nThis project is a fork of the akamai/hface project but highly slimmed.\nThe purpose of that project is to enable basic support for HTTP/1.1, HTTP/2 and HTTP/3 in urllib3.\n\n* HTTP/1.1, HTTP/2, and HTTP/3 support through respectively h11, h2 and aioquic\n* Sans-IO_ core with pluggable protocol implementations\n* Layered design with well-defined APIs\n* Client-oriented only\n\n.. _PyPI: https://pypi.org/project/urllib3-ext-hface\n\n.. _Sans-IO: https://sans-io.readthedocs.io/\n\nDocumentation\n-------------\n\nThis library is pretty straight forward and is very easy to understand.\n\n.. code-block:: python\n\n from urllib3_ext_hface import HTTPProtocolFactory, HTTP1Protocol, HTTP2Protocol, HTTP3Protocol\n\n protocol = HTTPProtocolFactory.new(HTTP2Protocol)\n\n # ...\n protocol.bytes_to_send() # Out to your network I/O implementation\n # ...\n protocol.bytes_received() # Whatever comes from your network I/O implementation\n # ...\n protocol.next_event() # Output the next event in order that the state-machine generated\n\nHere ``protocol`` is either of type ``HTTPOverQUICProtocol`` or ``HTTPOverTCPProtocol``, depending\non the foremost, you will either be on a DGRAM (UDP) or STREAM (TCP) socket.\n\nFind just bellow a somewhat stupid example that can help you get started.\n\n.. code-block:: python\n\n from urllib3_ext_hface import HTTPProtocolFactory, HTTP1Protocol, HTTP2Protocol, HTTP3Protocol\n import ssl\n import socket\n import certifi\n\n RECV_LENGTH = 4096\n\n if __name__ == \"__main__\":\n\n ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)\n ctx.set_alpn_protocols([\"h2\"])\n\n ctx.load_default_certs()\n ctx.load_verify_locations(certifi.where())\n\n sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n\n sock = ctx.wrap_socket(sock, server_hostname=\"httpbin.org\")\n\n sock.connect((\"httpbin.org\", 443))\n\n sock.settimeout(3)\n\n protocol = HTTPProtocolFactory.new(HTTP2Protocol)\n\n # Start HTTP2*PRI\n while True:\n data_out = protocol.bytes_to_send()\n\n if not data_out:\n break\n\n sock.sendall(data_out)\n\n protocol.bytes_received(\n sock.recv(RECV_LENGTH)\n )\n\n stream_id = protocol.get_available_stream_id()\n\n protocol.submit_headers(\n stream_id,\n [\n (b\":authority\", b\"httpbin.org\"),\n (b\":scheme\", b\"https\"),\n (b\":path\", b\"/headers\"),\n (b\":method\", b\"GET\"),\n (b\"User-Agent\", b\"Awesome Sans-IO!\")\n ],\n True\n )\n\n sock.sendall(\n protocol.bytes_to_send()\n )\n\n while True:\n\n try:\n protocol.bytes_received(\n sock.recv(RECV_LENGTH)\n )\n except TimeoutError:\n protocol.connection_lost()\n\n event = protocol.next_event()\n\n if hasattr(event, \"data\"):\n print(event.data)\n\n print(event)\n\n if hasattr(event, \"end_stream\") and event.end_stream is True:\n break\n\n protocol.submit_close()\n\n sock.sendall(protocol.bytes_to_send())\n\n sock.close()\n\nLicense\n-------\n\n::\n\n Copyright 2022 Akamai Technologies, Inc\n\n Licensed under the Apache License, Version 2.0 (the \"License\");\n you may not use this file except in compliance with the License.\n You may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\n Unless required by applicable law or agreed to in writing, software\n distributed under the License is distributed on an \"AS IS\" BASIS,\n WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n See the License for the specific language governing permissions and\n limitations under the License.\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "urllib3 extension to support HTTP/1.1, HTTP/2 and HTTP/3 independently of Python httplib",
"version": "0.3.4",
"project_urls": {
"Changelog": "https://github.com/Ousret/urllib3-ext-hface/blob/main/CHANGELOG.rst",
"Code": "https://github.com/Ousret/urllib3-ext-hface",
"Documentation": "https://urllib3.readthedocs.io",
"Issue tracker": "https://github.com/Ousret/urllib3-ext-hface/issues"
},
"split_keywords": [
"extension",
"h11",
"h2",
"h3",
"quic",
"urllib3"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f71ca1d421fb3e144514aec5a8cfdb147856766004bf650810e9aac3fa572a83",
"md5": "2725491c1db7d987cfc054b80e40601d",
"sha256": "ea12a8d0bcafd57d19af4251134adb80595e3631d1faa576ba2677a87d5b1d92"
},
"downloads": -1,
"filename": "urllib3_ext_hface-0.3.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2725491c1db7d987cfc054b80e40601d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 30021,
"upload_time": "2023-06-16T06:43:57",
"upload_time_iso_8601": "2023-06-16T06:43:57.472578Z",
"url": "https://files.pythonhosted.org/packages/f7/1c/a1d421fb3e144514aec5a8cfdb147856766004bf650810e9aac3fa572a83/urllib3_ext_hface-0.3.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8bcc0949733abbb6d329e78754877a2cea22435bb21616a843ca11a535324780",
"md5": "359b6c3da44f67674de7aecc3fd0c6b5",
"sha256": "172634bc3b73b02fb9f34ba653c623a99e2b7526fd0bc912e3a837d8e1b4c16e"
},
"downloads": -1,
"filename": "urllib3_ext_hface-0.3.4.tar.gz",
"has_sig": false,
"md5_digest": "359b6c3da44f67674de7aecc3fd0c6b5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 22687,
"upload_time": "2023-06-16T06:43:59",
"upload_time_iso_8601": "2023-06-16T06:43:59.047727Z",
"url": "https://files.pythonhosted.org/packages/8b/cc/0949733abbb6d329e78754877a2cea22435bb21616a843ca11a535324780/urllib3_ext_hface-0.3.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-16 06:43:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Ousret",
"github_project": "urllib3-ext-hface",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "urllib3-ext-hface"
}