std.http.Client: omit port in http host header sometimes#19637
Merged
std.http.Client: omit port in http host header sometimes#19637
Conversation
jacobly0
approved these changes
Apr 12, 2024
Member
jacobly0
left a comment
There was a problem hiding this comment.
The Uri.zig change from the second commit seems reasonable, but I agree that having uri.port == null is a much more reasonable representation than recomputing the default port later to check if it really was a default. This will also more faithfully copy location headers to host headers, where presumably the location header was set to a host that the server actually accepts.
This makes the host http header have the port if and only if the URI provided by the API user included it. Closes #19624
This makes the host http header have the port if and only if it differs from the defaults based on the protocol. This is an alternate implementation that closes #19624.
This reverts commit db0a42b, but keeps the changes to std/Uri.zig.
db0a42b to
0a3dff8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This branch contains two competing implementations that both result in avoiding ":443" in the HTTP host header for zig's package fetching.
The first commit implements it by making
std.http.Clientpass the port to the server based on user input. This makes the host http header have the port if and only if the URI provided by the API user included it.The second commit implements it a different way by making the host http header have the port if and only if it differs
from the defaults based on the protocol.
I think I like the first commit more actually, because it's simpler yet more flexible. What do you think, @jacobly0?
Closes #19624