hyperium / hyper

An HTTP library for Rust
https://hyper.rs
MIT License
14.58k stars 1.6k forks source link

how can i get addr from req when req.uri().authority() is None #2943

Closed kulame closed 2 years ago

kulame commented 2 years ago

hi i want to convert a http reqeust to a sockaddr like the golang hijack. https://pkg.go.dev/net/http#Hijacker

i try to follow the example https://github.com/hyperium/hyper/blob/master/examples/http_proxy.rs
but failed.

because the uri.authority() is None. how can I fetch the addr from req with the uri.authority() is None?

seanmonstar commented 2 years ago

Depends if the client sent a request with the address in URI or not. Many are just GET / HTTP/1.1, so then you need to check the host header instead, if it is sent.