Enhancement Suggestion: Validate URL Scheme in Tonic Channels
- Dominant language
- Rust
- Stars
- 12.5k
- Forks
- 1.3k
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 24
Description
## Bug Report
### Summary
I hope you're doing well! I wanted to bring up a small issue I've encountered while using Tonic. When creating a channel with the `grpc` URL scheme, I ran into some unexpected HTTP/2 parsing errors because the GRPC server expected the `:scheme` header value to be either `http` or `https`.
### Steps to Reproduce
Here’s the code I used to create the channel:
```rust
let channel = Channel::from_shared("grpc://127.0.0.1:50051")
.unwrap()
.connect()
.await;
```
### Problem
It seems that using the `grpc` scheme leads Tonic to send the request with the `grpc` scheme, but servers may only understand the values of `https` and `http`.
As a result, I encountered the following parsing error:
```
000 00:00:1728430246.326386 50275371 hpack_parser.cc:713] HTTP:1:HDR:SVR: :method: POST
E0000 00:00:1728430246.326399 50275371 hpack_parser.cc:1008] Error parsing ':scheme' metadata: invalid value
I0000 00:00:1728430246.326401 50275371 hpack_parser.cc:713] HTTP:1:HDR:SVR: :scheme: (parse error: INTERNAL: Error parsing ':scheme' metadata [type.googleapis.com/grpc.status.int.stream_id='0'])
```
### Suggestion
To enhance the user experience, it might be helpful if Tonic could validate that the URL scheme is either `http` or `https`. This small check could prevent others from encountering the same issue and help them have a smoother experience with Tonic.
### Version
Here’s the version information for your reference:
```
$ cargo tree | grep tonic
├── tonic v0.12.3
├── tonic-async-interceptor v0.12.0
│ ├── tonic v0.12.3 (*)
├── tonic-reflection v0.12.3
│ └── tonic v0.12.3 (*)
└── tonic-build v0.11.0
```
### Platform
I’m currently using the following platform:
```plaintext
Darwin Juno.local 23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:14:59 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8122 arm64
```
Thank you so much for your hard work on Tonic! I really appreciate it, and I hope this feedback is helpful!
Contributor guide
Assessment
This issue has not been assessed yet.