Skip to content

Conversation

@joseluisq
Copy link
Collaborator

@joseluisq joseluisq commented Oct 18, 2025

It resolves #569 and supersedes the previous one #570 by @CrazyCraftix accidentally closed.

Description

So far, the HTTP host header has been used to determine the hostname that is being accessed. In HTTP/2, this header is not guaranteed to be sent. Instead, the ":authority" pseudo-header field is used. I added a check for that header to make virtual hosts also work with HTTP/2.

Also I found out that the HTTP host header may also contain the port number, so I added a check to remove it if it's there.

How Has This Been Tested?

Not thoroughly, just manually for my usecase, so there may still be problems I didn't consider.
I suppose an automated test would be nice but I'm not sure what's the best way to do this.

See unit tests added.

crazycraftix and others added 2 commits October 13, 2025 22:32
So far, the HTTP host header has been used to determine the hostname
that is being accessed. In HTTP/2, this header is not guaranteed to be
sent. Instead, the ":authority" pseudo-header field is used. This commit
adds a check for that header to make virtual hosts also work with
HTTP/2.

Additionally, this commit adds code to check and remove the port number,
which may or may not be sent as part of the HTTP host header.
@joseluisq joseluisq added v2 v2 release bugfix This is PR fixes a bug labels Oct 18, 2025
@semanticdiff-com
Copy link

semanticdiff-com bot commented Oct 18, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  src/virtual_hosts.rs  19% smaller

Comment on lines +21 to +23
if vhosts.is_empty() {
return None;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, new lines added.

}

#[cfg(test)]
mod tests {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, some tests were added too.

@joseluisq joseluisq assigned joseluisq and unassigned joseluisq Oct 18, 2025
@joseluisq joseluisq merged commit 2549119 into master Oct 18, 2025
38 checks passed
@joseluisq joseluisq deleted the vhost-authority branch October 18, 2025 04:35
@joseluisq
Copy link
Collaborator Author

@CrazyCraftix PR merged and is ready for the next release. Thanks!

@joseluisq joseluisq added this to the v2.38.2 milestone Oct 18, 2025
@joseluisq joseluisq modified the milestones: v2.38.2, v2.39.0 Oct 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix This is PR fixes a bug v2 v2 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Virtual Hosts don't work with HTTP/2

2 participants