go - how to keep key case sensitive in request header using golang? -



go - how to keep key case sensitive in request header using golang? -

i using golang library "net/http",while add together header info request, found header keys changing, e.g

request, _ := &http.newrequest("get", fakeurl, nil) request.header.add("mykey", "myvalue") request.header.add("mykey2", "mynewvalue") request.header.add("dont-change-me","no")

however, when fetch http message package, found header key changed this:

mykey: myvalue mykey2: mynewvalue dont-change-me: no

i using golang 1.3, how maintain key case sensitive or maintain origin looking? thx.

the http.header add , set methods canonicalize header name when adding values header map. can sneak around canonicalization adding values using map operations:

request.header["mykey"] = []string{"myvalue"} request.header["mykey2"] = []string{"mynewvalue"} request.header["dont-change-me"] = []string{"no"}

as long utilize canonical names headers known transport, should work.

go header request case-sensitive

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -