Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This work presents a significantly simplified implementation of `httpx`.
* Seriously, a [radically simplified implementation](https://github.com/encode/httpnext/blob/main/src/httpx/_client.py). While still fulfiling the same set of functionality.
* A consistent & tightly typed set of HTTP components, with immutability throughout. Includes URLs, Query Parameters, Headers, Form & File interfaces, all of which are suitable for either client side or server side codebases.
* A re-engineered [connection pool implementation](https://github.com/encode/httpnext/blob/main/src/httpx/_pool.py), with tighter more obvious concurrency handling.
* The core networking component is simple enough to be directly included. There is no `httpx`/`httpcore` split, and the only hard dependencies here are `h11` and `truststore`.
* The core networking component is simple enough to be directly included. The only hard dependency here is `h11`.
* Seperately namespaced packages for `ahttpx` and `httpx`.

There is also preliminary work ongoing for httpx *for both client-side and server-side usage*.
Expand Down Expand Up @@ -75,7 +75,6 @@ Package and dependencies...

* httpx
* h11
* truststore

---

Expand Down
5 changes: 2 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This work insteads presents a significantly simplified implementation of `httpx`
* Preliminary work for httpx to support both client-side and server-side usages.

* A re-engineered [connection pool implementation](https://github.com/encode/httpx-insiders/blob/main/src/httpx/_pool.py), with tighter more obvious concurrency handling.
* The core networking component is simple enough to be directly included. The only hard dependencies here are `h11` and `truststore`.
* The core networking component is simple enough to be directly included. The only hard dependency here is `h11`.
* Seperately namespaced packages for `ahttpx` and `httpx`.

There is also preliminary work ongoing for httpx *for both client-side and server-side usage*.
Expand Down Expand Up @@ -98,7 +98,6 @@ Package and dependencies...

* httpx
* h11
* truststore

---

Expand All @@ -124,4 +123,4 @@ Our credentials to date include authorship of signifcant parts of the Python dev

---

<p align="center"><i>This provisional design work is <a href="https://www.encode.io/httpnext/about/">not currently licensed</a> for reuse.</i><br/>&mdash; 🦋 &mdash;</p>
<p align="center"><i>This provisional design work is <a href="https://www.encode.io/httpnext/about">not currently licensed</a> for reuse.</i><br/>&mdash; 🦋 &mdash;</p>
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ classifiers = [
]
dependencies = [
"h11==0.*",
"truststore==0.10",
]
14 changes: 10 additions & 4 deletions src/ahttpx/_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ async def open_connection_pool(
backend: NetworkBackend | None = None
) -> ConnectionPool:
if ssl_context is None:
import truststore
ssl_context = truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
ssl_context = create_default_context()
if backend is None:
backend = NetworkBackend()

Expand Down Expand Up @@ -343,8 +342,15 @@ async def open_connection(
stream = await backend.connect(host, port)
if url.scheme == "https":
if ssl_context is None:
import truststore
ssl_context = truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
ssl_context = create_default_context()
await stream.start_tls(ssl_context, hostname=hostname)

return Connection(stream, url)


def create_default_context() -> ssl.SSLContext:
try:
import certifi
except ImportError:
return ssl.create_default_context()
ssl.create_default_context(cafile=certifi.where())
14 changes: 10 additions & 4 deletions src/httpx/_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,7 @@ def open_connection_pool(
backend: NetworkBackend | None = None
) -> ConnectionPool:
if ssl_context is None:
import truststore
ssl_context = truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
ssl_context = create_default_context()
if backend is None:
backend = NetworkBackend()

Expand Down Expand Up @@ -343,8 +342,15 @@ def open_connection(
stream = backend.connect(host, port)
if url.scheme == "https":
if ssl_context is None:
import truststore
ssl_context = truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
ssl_context = create_default_context()
stream.start_tls(ssl_context, hostname=hostname)

return Connection(stream, url)


def create_default_context() -> ssl.SSLContext:
try:
import certifi
except ImportError:
return ssl.create_default_context()
ssl.create_default_context(cafile=certifi.where())