Why http header letter case changes?

92 views
Skip to first unread message

dc0d

unread,
Sep 19, 2017, 10:59:36 PM9/19/17
to golang-nuts
It is true that http header keys are case-nonsensitive. Then why the letter case gets changed inside "*http.Response"?

An "ETag" header added and in the response we had "Etag" (the letter T converted to lowercase).

I've encountered this when doing some testing and this behavior was unpleasant and unexpected.

Volker Dobler

unread,
Sep 20, 2017, 4:45:11 AM9/20/17
to golang-nuts
The header keys are canonicalized.

Unfortunately the standard canonical form of "ETag" is "Etag".
The ETag header is the only HTTP header key which is not in
the standard canonical form. Fortunately any compliant implementation
will ignore capitalization of the header keys so this should never be
a problem. It is just a small inconsistency.

V.
Reply all
Reply to author
Forward
0 new messages