Skip to content

Commit

Permalink
Drop urllib3 in favor of public gist
Browse files Browse the repository at this point in the history
  • Loading branch information
florimondmanca committed Aug 15, 2020
1 parent b9db5e1 commit dd08a60
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 156 deletions.
15 changes: 11 additions & 4 deletions docs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -809,24 +809,31 @@ 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.

### Writing custom transports

A transport instance must implement the Transport API defined by
[`httpcore`](https://www.encode.io/httpcore/api/). You
should either subclass `httpcore.AsyncHTTPTransport` to implement a transport to
use with `AsyncClient`, or subclass `httpcore.SyncHTTPTransport` to implement a
transport to use with `Client`.

For example, HTTPX ships with a transport that uses the excellent
[`urllib3` library](https://urllib3.readthedocs.io/en/latest/), which can be
### Examples

#### 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`...

```python
>>> 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`.
#### Custom transport

A complete example of a custom transport implementation would be:

Expand Down
8 changes: 8 additions & 0 deletions docs/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,11 @@ 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`.

If you're transitioning from Requests to HTTPX, you might want to consider using HTTPX with an [`urllib3` custom transport](/advanced#urllib3-transport) at first, so that `urllib3` is retained as the underlying HTTP networking implementation, allowing you to deal with any differences in behavior as a second phase.
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 @@ -99,8 +98,6 @@
"WriteError",
"WriteTimeout",
"URL",
"URLLib3Transport",
"URLLib3ProxyTransport",
"Cookies",
"Headers",
"QueryParams",
Expand Down
149 changes: 0 additions & 149 deletions httpx/_transports/urllib3.py

This file was deleted.

0 comments on commit dd08a60

Please sign in to comment.