Monday, November 17, 2025
HomeGolangRequest Header Altering to Canonical kind - Getting Assist

Request Header Altering to Canonical kind – Getting Assist


I’m attempting to make a put up to an URL and I would like to make sure that the headers case matches. Instance I’ve a header referred to as HealthCheck, however after I make the put up the server receives the important thing as Healthcheck, the place the C is now in lowercase.
I attempted
req.Header.Set("HealthCheck", "Take a look at")
and
req.Header.Add("HealthCheck", "Take a look at")
and
req.Header["HealthCheck"] = []string{"Take a look at"}
and the error I get is lacking header HealthCheck . The header obtained on the servers facet is Healthcheck they usually want this to be within the Case as they specified.
I do know that GO is altering the header to it canonical kind, however is there a approach to keep away from it. The server the place I’m posting this to has thousands and thousands of customers and they don’t seem to be going to make any adjustments on their finish. I’ve to provide you with an answer for this.
Additionally I could make the request simply in Python and the headers keep as I would like them to be.
Thanks prematurely

Hello, as written in official doc it is best to

To make use of non-canonical keys, assign to the map straight.

Is the final one not working ?

One other subject, the usual says that header are case-insensitive. So I’d say that the issue is server facet as a result of appears prefer it’s doing case-sensitive comparability

Thanks for the Assist Massimo!
You’re right about each the issues! 1st, Assigning utilizing map labored so long as I assigned all header keys utilizing that.
You’re additionally right concerning the server facet being applied improper, I attempted telling them that, however couldn’t care much less.

Admire your assist!
Cheers

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments