Skip to content

No verbatim headers possible #51

Answered by earthboundkid
milabs asked this question in Ideas
Discussion options

You must be logged in to vote

In theory, it shouldn't matter but in practice, some servers suck. I had this problem when I was using Ruby to talk to some government server back in 2016, so I'm definitely sympathetic to the issue.

I hate to junk up the main interface for what's really a workaround for the server sucking. Maybe a custom transport? In most cases, I guess you probably just need all lowercase or something, so maybe just write

LowercaseHeaders := requests.RoundTripFunc(func(req *http.Request) (res *http.Response, err error) {
	req2 := *req
	req2.Header = make(http.Header, len(req.Header))
	for k, v := range req.Header {
		req2.Header[strings.ToLower(k)] = v
	}
	return http.DefaultTransport.RoundTrip(&req2)
})

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@milabs
Comment options

Answer selected by earthboundkid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants