Are HTTP headers (Content-Type, &c.) case-sensitive?

25,093

Solution 1

Case-insensitive.

Hypertext Transfer Protocol -- HTTP/1.1:

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.

Solution 2

Looks like the MIME type in a Content-type header value is case-insensitive, so application/PDF and application/pdf are equivalent. It does say parameter values are case-sensitive, so technically "text/html; charset=UTF-8" is not equivalent to "text/html; charset=utf-8". But that's not a good example because http://www.w3.org/TR/html4/charset.html#h-5.2.1 says "Names for character encodings are case-insensitive".

http://www.w3.org/Protocols/rfc1341/4_Content-Type.html

The type, subtype, and parameter names are not case sensitive. For example, TEXT, Text, and TeXt are all equivalent. Parameter values are normally case sensitive, but certain parameters are interpreted to be case- insensitive, depending on the intended use. (For example, multipart boundaries are case-sensitive, but the "access- type" for message/External-body is not case-sensitive.)

Share:
25,093

Related videos on Youtube

anonymous coward
Author by

anonymous coward

SOreadytohelp

Updated on March 24, 2020

Comments

  • anonymous coward
    anonymous coward about 4 years

    Perhaps I'm skimming too fast, but couldn't find this specifically documented. In my particular case, I'm wondering about the "Content-Type" header, but I'm assuming the same rules would apply to other standard headers.

    Are these case sensitive, and if so: Is it Content-Type or Content-type?

    Is there a proper place to reference these?

  • Shashank Kadne
    Shashank Kadne about 12 years
    Are field values case-insensitive too??
  • Roman R.
    Roman R. about 12 years
    With rare exceptions they are too case-insensitive, however you need to check with RFC each time you are in doubts.
  • Shashank Kadne
    Shashank Kadne about 12 years
    Tell me if application/pdf and application/PDF are equal ?? I assume no..
  • EricLaw
    EricLaw over 11 years
    MIME types are interpreted case-insensitively.
  • Simon Tewsi
    Simon Tewsi over 7 years
    Note that RFC 1341 has been obsoleted by RFC 2045. However the text relating to case sensitivity quoted from RFC 1341 doesn't seem to have changed in RFC 2045.
  • Arend v. Reinersdorff
    Arend v. Reinersdorff about 6 years
    @SimonTewsi I couldn't find this info in RFC 2045. It seems RFC 7231 section 3.1.1.1 is the correct one.
  • Simon Tewsi
    Simon Tewsi about 6 years
    @Arendv.Reinersdorff: See RFC 2045 section 5.1, Syntax of the Content-Type Header Field. It's on the second page of the section.
  • Arend v. Reinersdorff
    Arend v. Reinersdorff about 6 years
    @SimonTewsi Thanks for pointing it out, I missed it :-)
  • Marco
    Marco over 3 years
    For ref on MIME types case sensitivity: tools.ietf.org/html/rfc2045#section-5.1