Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Request.Headers["Header-Name"] in ASP.NET case-sensitive?

Is Request.Headers["Header-Name"] in ASP.NET case-sensitive? And if it is, how should I get a certain header (e.g. "X-requested-with") if I don't know for sure what case the client will send it in?

like image 516
SlimShaggy Avatar asked Jul 23 '12 16:07

SlimShaggy


People also ask

Is request headers case sensitive?

officially, headers are case insensitive, however, it is common practice to capitalize the first letter of every word.

Is ASP Net case sensitive?

Yes the web. config file as well as Import directives and other portions of ASP.net are case sensitive. If you are using a case insensitive programming language some of this may change.

Should HTTP headers be lowercase?

All HTTP header keys are converted to lowercase in both directions (since HTTP header keys are defined to be case-insensitive). You should use lowercase in all of your mapping and classification rules.

What is the format of request header?

HTTP headers let the client and the server pass additional information with an HTTP request or response. An HTTP header consists of its case-insensitive name followed by a colon ( : ), then by its value. Whitespace before the value is ignored.


1 Answers

no they are case-insensitive as per RFC2616

4.2 Message Headers

HTTP header fields, which include general-header (section 4.5),
request-header (section 5.3), response-header (section 6.2), and
entity-header (section 7.1) fields, follow the same generic format as that given in Section 3.1 of RFC 822 [9]. Each header field consists
of a name followed by a colon (":") and the field value. Field names
are case-insensitive. The field value MAY be preceded by any amount
of LWS, though a single SP is preferred. Header fields can be
extended over multiple lines by preceding each extra line with at
least one SP or HT. Applications ought to follow "common form", where one is known or indicated, when generating HTTP constructs, since
there might exist some implementations that fail to accept anything

like image 160
HatSoft Avatar answered Sep 26 '22 01:09

HatSoft