Reputation: 41
I need to collect a bunch of http headers. The only way I found yet is *http.Request .Header.Get("%header name%")
Is there any name conventions for %header name% ?
E.g. in PHP all keys are uppercased, words separated with underscore.
Upvotes: 0
Views: 5537
Reputation: 120951
The keys in a header are in canonical format.
The Header methods canonicalize the the key for you.
If the application accesses the header map directly, then the application is responsible for ensuring that the key is in canonical format.
Some examples of header names in canonical format are:
Content-Length
Etag
You can find all headers using range:
for name, values := range req.Header {
fmt.Printf("%s: %v\n", name, values)
}
Upvotes: 6