Skip to content

Commit

Permalink
Merge branch 'master' into beijen/small-typo-in-docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mbeijen committed Apr 12, 2024
2 parents 35756a6 + 7354ed7 commit 3befbf0
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 10 deletions.
41 changes: 41 additions & 0 deletions docs/advanced/extensions.md
Expand Up @@ -138,6 +138,47 @@ response = client.get(

This extension is how the `httpx` timeouts are implemented, ensuring that the timeout values are associated with the request instance and passed throughout the stack. You shouldn't typically be working with this extension directly, but use the higher level `timeout` API instead.

### `"target"`

The target that is used as [the HTTP target instead of the URL path](https://datatracker.ietf.org/doc/html/rfc2616#section-5.1.2).

This enables support constructing requests that would otherwise be unsupported.

* URL paths with non-standard escaping applied.
* Forward proxy requests using an absolute URI.
* Tunneling proxy requests using `CONNECT` with hostname as the target.
* Server-wide `OPTIONS *` requests.

Some examples:

Using the 'target' extension to send requests without the standard path escaping rules...

```python
# Typically a request to "https://www.example.com/test^path" would
# connect to "www.example.com" and send an HTTP/1.1 request like...
#
# GET /test%5Epath HTTP/1.1
#
# Using the target extension we can include the literal '^'...
#
# GET /test^path HTTP/1.1
#
# Note that requests must still be valid HTTP requests.
# For example including whitespace in the target will raise a `LocalProtocolError`.
extensions = {"target": b"/test^path"}
response = httpx.get("https://www.example.com", extensions=extensions)
```

The `target` extension also allows server-wide `OPTIONS *` requests to be constructed...

```python
# This will send the following request...
#
# CONNECT * HTTP/1.1
extensions = {"target": b"*"}
response = httpx.request("CONNECT", "https://www.example.com", extensions=extensions)
```

## Response Extensions

### `"http_version"`
Expand Down
2 changes: 1 addition & 1 deletion docs/api.md
Expand Up @@ -114,7 +114,7 @@ what gets sent over the wire.*
'example.org'
```

* `def __init__(url, allow_relative=False, params=None)`
* `def __init__(url, **kwargs)`
* `.scheme` - **str**
* `.authority` - **str**
* `.host` - **str**
Expand Down
16 changes: 8 additions & 8 deletions requirements.txt
Expand Up @@ -11,19 +11,19 @@ chardet==5.2.0
# Documentation
mkdocs==1.5.3
mkautodoc==0.2.0
mkdocs-material==9.5.12
mkdocs-material==9.5.16

# Packaging
build==1.1.1
build==1.2.1
twine==5.0.0

# Tests & Linting
coverage[toml]==7.4.3
coverage[toml]==7.4.4
cryptography==42.0.5
mypy==1.8.0
pytest==8.0.2
ruff==0.3.0
trio==0.24.0
mypy==1.9.0
pytest==8.1.1
ruff==0.3.4
trio==0.25.0
trio-typing==0.10.0
trustme==1.1.0
uvicorn==0.27.1
uvicorn==0.29.0
2 changes: 1 addition & 1 deletion tests/conftest.py
Expand Up @@ -236,7 +236,7 @@ def url(self) -> httpx.URL:
def install_signal_handlers(self) -> None:
# Disable the default installation of handlers for signals such as SIGTERM,
# because it can only be done in the main thread.
pass
pass # pragma: nocover

async def serve(self, sockets=None):
self.restart_requested = asyncio.Event()
Expand Down

0 comments on commit 3befbf0

Please sign in to comment.