2

In PHP, the documentation says that you can replace previously set headers via the second, boolean, argument to header().

I'm wondering: Are HTTP headers case-sensitive or normalized in any way?

If I use:

    header('Content-Type: text/plain');
    header('Content-type: text/html');

... will it send one, or two different headers?

Similarly, if I use:

    header('Content-Type: text/plain');
    header('Content-type: text/html', TRUE);

... will that (properly?) replace the first?

anonymous coward
  • 12,594
  • 13
  • 55
  • 97
  • 1
    You can test it with your browser's developer tool. Run a script with your given lines, and check the response headers the browser receives. – BoltClock Oct 10 '11 at 20:57
  • Judging by your previous question, are you having a problem related to this topic? If so... just post your problem directly; you'll get an answer faster if you just ask the real question. – Chris Baker Oct 10 '11 at 21:04
  • 1
    "Real problem" is alleged by someone that part of an app is sending multiple "Content-type" headers. My presumption is that they are wrong. Rather than guess around, I started researching, and asked the HTTP-specific question. I followed up by adding this PHP-specific version to add to the community more google-able results; also, in the event that someone might present a particular peculiarity with PHP that might have slipped by other assumptions. – anonymous coward Oct 10 '11 at 21:09

1 Answers1

2

According to the RFC 2616, HTTP header field names are case-insensitive.

PHP does get this right, and replaces the first header with the second.

Brad
  • 159,648
  • 54
  • 349
  • 530
  • This was mentioned in an answer to [his previous question](http://stackoverflow.com/questions/7718476/are-http-headers-content-type-c-case-sensitive) - this question kinda sorta asks if PHP complies with it. – BoltClock Oct 10 '11 at 20:59