cloudflare / cloudflare/pingora
Header Availability with HTTP and HTTPS Request
- Dominant language
- Rust
- Stars
- 27.4k
- Forks
- 1.7k
- Avg merge
- 6h 22m
- Merged PRs (30d)
- 3
Description
## Describe the bug
I am unsure if it is my lack of understanding of how HTTP/HTTPS works but it seems I have to use different ways of getting the HOST header during an HTTP and HTTPS request. I would think it would be the same.
## Pingora info
Please include the following information about your environment:
**Pingora version**: 0.1.0
**Rust version**: cargo 1.76.0 (c84b36747 2024-01-18)
**Operating system version**: Arch Linux - Kernel 6.7.9
## Steps to reproduce
During an HTTPS request I can retrieve the HOST header with the following code:
`_session.req_header().uri.host().unwrap();`
During an HTTP request I can retrieve the HOST header with the following code:
`_session.get_header("Host").unwrap().to_str().unwrap().split(":").collect::>()[0].to_string();`
I do the extra split code to just get the HOST without the port.
If you try to use the HTTPS method within the HTTP request you will get an error on the unwrap and vice versa with HTTP method.
Both scenarios are during the request_filters portion of the request.
## Expected results
I would expect either method to return the HOST header in either situation. Though maybe I misunderstand. I would prefer the HTTPS method of retrieving the HOST header as it seems simpler to me.
## Observed results
You should receive an error when trying to unwrap or access the requested header.
## Additional context
Now I am specifically looking at the HOST header but I think any other header would act the same way. This behavior seems odd to me but maybe that is just how HTTP vs HTTPS works. Thanks.
Contributor guide
Assessment
This issue has not been assessed yet.