-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
resources.GetRemote: User-Agent header is ignored #10616
Comments
If I'm reading the code right, the correct fix would be to switch the order between addDefaultHeaders/addUserProvidedHeaders -- as addDefaultHeaders checks for preexisting values for the default keys before adding. I don't think we can use |
True, inverting the function might be the best way to deal with this. There are also some other weird behavior, still with the example in my first post, I can for example override the |
Whatever it is, it's the |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
What version of Hugo are you using:
hugo v0.109.0-47b12b83e636224e5e601813ff3e6790c191e371+extended windows/amd64 BuildDate=2022-12-23T10:38:11Z VendorInfo=gohugoio
Does this issue reproduce with the latest release : Yes
Hello,
I’m currently doing some work that requires me to change the user agent of the client used for
resources.GetRemote
Unfortunately, it seems that I'm unable to modify the
User-Agent
header, consider the following example:The server sees:
From what I can read in remote.go#L98 it seems that
addDefaultHeaders
is call first which sets theUser-Agent
header toHugo Static Site Generator
and then,addUserProvidedHeaders
is called.This functions uses
req.Header.Add
to add the header. The issue is that.Add
does not override an existing header. Wouldn't it be preferable to use.Set
which according to the documentationreplaces any existing values associated with key
?Samuel,
The text was updated successfully, but these errors were encountered: