Skip to content

Unclear how to get request host #676

@stepancheg

Description

@stepancheg

What is the problem your feature solves, or the need it fulfills?

This is code I have

    async fn upstream_peer(
        &self,
        session: &mut Session,
        _ctx: &mut Self::CTX,
    ) -> pingora::Result<Box<HttpPeer>> {
        let Some(host) = session.req_header().uri.host() else {
            return Err(pingora::Error::new_str("host unset"));
        };

it reports host unset. Which is probably expected. But then how do I get host? I guess

session.req_header().headers.get("host")

or

session.req_header().headers.get(":authority")

or both?

Describe the solution you'd like

Add a function like

RequestHeader::host(&self) -> &str

Describe alternatives you've considered

Continue reading sources.

Additional context

0.5.0

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions