Skip to content
Open
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
16 changes: 16 additions & 0 deletions docs/user_guide/modify_filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ impl ProxyHttp for MyGateway {
```


## Accessing request headers

Request headers can be accessed through `session.req_header()`. For HTTP/1.1 and HTTP/2 requests, the API provides a unified interface for header access.

### Host header

To get the request host, use the standard `HOST` header. For HTTP/2 requests, Pingora automatically maps the `:authority` pseudo-header to the `HOST` header for compatibility.

```Rust
use http::header::HOST;

let host = session.req_header().headers.get(HOST);
```

For HTTP/1.1 requests, this returns the `Host` header value. For HTTP/2 requests, this returns the `:authority` pseudo-header value.

## Modifying headers

Both request and response headers can be added, removed or modified in their corresponding phases. In the following example, we add logic to the `response_filter` phase to update the `Server` header and remove the `alt-svc` header.
Expand Down