Skip to content

std.http.Client: omit port in http host header sometimes#19637

Merged
andrewrk merged 3 commits intomasterfrom
http-host-port
Apr 13, 2024
Merged

std.http.Client: omit port in http host header sometimes#19637
andrewrk merged 3 commits intomasterfrom
http-host-port

Conversation

@andrewrk
Copy link
Member

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.Client pass 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

@andrewrk andrewrk requested a review from jacobly0 April 12, 2024 22:23
Copy link
Member

@jacobly0 jacobly0 left a comment

Choose a reason for hiding this comment

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

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.
@andrewrk andrewrk enabled auto-merge April 13, 2024 05:37
@andrewrk andrewrk merged commit 54d1a52 into master Apr 13, 2024
@andrewrk andrewrk deleted the http-host-port branch April 13, 2024 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Regression] Fetching dependency from codeberg.org causes it to return 503

2 participants