Request Header Changing to Canonical form

I am trying to make a post to an URL and I need to ensure that the headers case matches. Example I have a header called HealthCheck, but when I make the post the server receives the key as Healthcheck, where the C is now in lowercase.
I tried
req.Header.Set("HealthCheck", "Test")
req.Header.Add("HealthCheck", "Test")
req.Header["HealthCheck"] = []string{"Test"}
and the error I get is missing header HealthCheck . The header received on the servers side is Healthcheck and they need this to be in the Case as they specified.
I know that GO is changing the header to it canonical form, but is there a way to avoid it. The server where I am posting this to has millions of users and they are not going to make any changes on their end. I have to come up with a solution for this.
Also I can make the request easily in Python and the headers stay as I want them to be.
Thanks in advance

Hi, as written in official doc you should

To use non-canonical keys, assign to the map directly.

Is the last one not working ?

Another topic, the standard says that header are case-insensitive. So I’d say that the problem is server side because looks like it’s doing case-sensitive comparison

Thanks for the Help Massimo!
You are correct about both the things! 1st, Assigning using map worked as long as I assigned all header keys using that.
You are also correct about the server side being implemented wrong, I tried telling them that, but couldn’t care less.

Appreciate your help!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.