Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are the HTTP Connection header values case sensitive?

Are values such as keep-alive, Close, and Upgrade of the Connection: header case sensitive?

I'm writing a simple web server and wondering whether I should be transforming the values to lower case before checking them.

like image 951
Luke Avatar asked Jun 08 '12 17:06

Luke


2 Answers

I can’t find any explicit specification of the case-sensitivity of the Connection’s field values. But as Connection may contain the name of header fields:

[…] for each connection-token in this field, remove any header field(s) from the message with the same name as the connection-token.

and as those header field names are case-insensitive, I conclude that the Connection’s field value is also considered case-insensitive.

like image 131
Gumbo Avatar answered Sep 18 '22 17:09

Gumbo


No, the Connection header values (a.k.a. "connection options") are case-insensitive. The updated HTTP 1.1 RFC 7230, in section 6.1 states:

The Connection header field's value has the following grammar:

Connection        = 1#connection-option
connection-option = token

Connection options are case-insensitive.

My bold. Note that all header fields are case-insensitive.

Each header field consists of a case-insensitive field name...

Of course, keep in mind that this is just what the specification says. It doesn't mean that all browser, server, etc. implementations are compliant (or bug-free ;)

like image 26
Hawkeye Parker Avatar answered Sep 19 '22 17:09

Hawkeye Parker