Skip to content

Commit

Permalink
Drop urllib3 in favor of public gist (#1182)
Browse files Browse the repository at this point in the history
* Drop urllib3 in favor of public gist

* Drop urllib3 coverage omit

* Drop recommendation to use urllib3 transport during Requests migration

* Add urllib3-transport to 3p pkgs

* Drop urllib3 from dependencies list in README / docs home page

Co-authored-by: Tom Christie <tom@tomchristie.com>
  • Loading branch information
florimondmanca and tomchristie authored Sep 4, 2020
1 parent 642aabd commit 8fa8765
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 160 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ The HTTPX project relies on these excellent libraries:
* `rfc3986` - URL parsing & normalization.
* `idna` - Internationalized domain name support.
* `sniffio` - Async library autodetection.
* `urllib3` - Support for the `httpx.URLLib3Transport` class. *(Optional)*
* `brotlipy` - Decoding for "brotli" compressed responses. *(Optional)*

A huge amount of credit is due to `requests` for the API layout that
Expand Down
13 changes: 8 additions & 5 deletions docs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,8 @@ HTTPX's `Client` also accepts a `transport` argument. This argument allows you
to provide a custom Transport object that will be used to perform the actual
sending of the requests.

### Usage

For some advanced configuration you might need to instantiate a transport
class directly, and pass it to the client instance. The `httpcore` package
provides a `local_address` configuration that is only available via this
Expand Down Expand Up @@ -850,18 +852,19 @@ do not include any default values for configuring aspects such as the
connection pooling details, so you'll need to provide more explicit
configuration when using this API.

HTTPX also currently ships with a transport that uses the excellent
[`urllib3` library](https://urllib3.readthedocs.io/en/latest/), which can be
used with the sync `Client`...
### urllib3 transport

This [public gist](https://gist.github.com/florimondmanca/d56764d78d748eb9f73165da388e546e) provides a transport that uses the excellent [`urllib3` library](https://urllib3.readthedocs.io/en/latest/), and can be used with the sync `Client`...

```pycon
>>> import httpx
>>> client = httpx.Client(transport=httpx.URLLib3Transport())
>>> from urllib3_transport import URLLib3Transport
>>> client = httpx.Client(transport=URLLib3Transport())
>>> client.get("https://example.org")
<Response [200 OK]>
```

Note that you'll need to install the `urllib3` package to use `URLLib3Transport`.
### Writing custom transports

A transport instance must implement the Transport API defined by
[`httpcore`](https://www.encode.io/httpcore/api/). You
Expand Down
6 changes: 6 additions & 0 deletions docs/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,9 @@ Besides, `httpx.Request()` does not support the `auth`, `timeout`, `allow_redire
## Mocking

If you need to mock HTTPX the same way that test utilities like `responses` and `requests-mock` does for `requests`, see [RESPX](https://github.com/lundberg/respx).

## Networking layer

`requests` defers most of its HTTP networking code to the excellent [`urllib3` library](https://urllib3.readthedocs.io/en/latest/).

On the other hand, HTTPX uses [HTTPCore](https://github.com/encode/httpcore) as its core HTTP networking layer, which is a different project than `urllib3`.
1 change: 0 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ The HTTPX project relies on these excellent libraries:
* `rfc3986` - URL parsing & normalization.
* `idna` - Internationalized domain name support.
* `sniffio` - Async library autodetection.
* `urllib3` - Support for the `httpx.URLLib3Transport` class. *(Optional)*
* `brotlipy` - Decoding for "brotli" compressed responses. *(Optional)*

A huge amount of credit is due to `requests` for the API layout that
Expand Down
10 changes: 10 additions & 0 deletions docs/third-party-packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,13 @@ An asynchronous GitHub API library. Includes [HTTPX support](https://gidgethub.r
[GitHub](https://github.com/lundberg/respx) - [Documentation](https://lundberg.github.io/respx/)

A utility for mocking out the Python HTTPX library.

## Gists

<!-- NOTE: this list is in alphabetical order. -->

### urllib3-transport

[GitHub](https://gist.github.com/florimondmanca/d56764d78d748eb9f73165da388e546e)

This public gist provides an example implementation for a [custom transport](/advanced#custom-transports) implementation on top of the battle-tested [`urllib3`](https://urllib3.readthedocs.io) library.
3 changes: 0 additions & 3 deletions httpx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
from ._models import URL, Cookies, Headers, QueryParams, Request, Response
from ._status_codes import StatusCode, codes
from ._transports.asgi import ASGITransport
from ._transports.urllib3 import URLLib3ProxyTransport, URLLib3Transport
from ._transports.wsgi import WSGITransport

__all__ = [
Expand Down Expand Up @@ -101,8 +100,6 @@
"TransportError",
"UnsupportedProtocol",
"URL",
"URLLib3ProxyTransport",
"URLLib3Transport",
"WriteError",
"WriteTimeout",
"WSGITransport",
Expand Down
149 changes: 0 additions & 149 deletions httpx/_transports/urllib3.py

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/coverage
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export SOURCE_FILES="httpx tests"

set -x

${PREFIX}coverage report --omit=httpx/_transports/urllib3.py --show-missing --skip-covered --fail-under=100
${PREFIX}coverage report --show-missing --skip-covered --fail-under=100

0 comments on commit 8fa8765

Please sign in to comment.