Clarity needed on HTTP/2 headers with gRPC requests
- Dominant language
- Rust
- Stars
- 12.5k
- Forks
- 1.3k
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 24
Description
First of all, thanks for this wonderful library, so far it worked great for our use case.
### Problem
I want to create requests using `Request` struct from this page [https://docs.rs/tonic/latest/tonic/struct.Request.html](https://docs.rs/tonic/latest/tonic/struct.Request.html) and have easy access to HTTP/2 headers like `:scheme`, `:method`, `:authority`, and so forth.
### More specifically
I am currently testing our proxy with the following command:
```
printf '\x00\x00\x00\x00\x00' | curl -k -o - --data-binary @- --http2-prior-knowledge -iv -H 'Content-Type:application/grpc' -H 'Host: sample.host.net' https://generic-proxy.net/v1.service.Upstream/ReflectHeaders
```
The `curl` command gives a nice output on which headers are being sent upstream:
```
* using HTTP/2
* [HTTP/2] [1] OPENED stream for
* [HTTP/2] [1] [:method: POST]
* [HTTP/2] [1] [:scheme: https]
* [HTTP/2] [1] [:authority: sample.host.net]
* [HTTP/2] [1] [:path: /v1.service.Upstream/AddIntegers]
* [HTTP/2] [1] [user-agent: curl/8.7.1]
* [HTTP/2] [1] [accept: */*]
* [HTTP/2] [1] [content-type: application/grpc]
> POST /v1.service.Upstream/ReflectHeaders HTTP/2
> Host: sample.host.net
```
Same can be done with `grpcurl` by setting `-authority` and other headers. By tweaking my `curl` command to use a custom `Host` I can see that `:authority` sent upstream is changing as well, which is what I expect when working with HTTP/2 requests and this is something we are testing for our proxy.
### Ask
I would like more clarity on how to set `authority` headers to enable better configuration over the `Request` sent to the origin. (1) is it possible today with `tonic`, because I searched for string `authority` on all doc pages and only found it inside `Uri` where authority is just part of a url, not an HTTP/2 pseudoheader `:authority`, (2) if it's not possible, are there any plans to do so?
### Ideal case
Ideally I would like to call `.authority()` on both the `Request`/`Response` and check what was sent over HTTP/2.
### Intermediate ask
What is more confusing is that even after setting RUST_LOG to trace and debug and others I can't see ANY output on what authority is being used/sent upstream. And I also can't get `tonic_request.metadata().get(":authority")` of the constructed request, which is unexpected.
Contributor guide
Assessment
This issue has not been assessed yet.