php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17359 wrong header sent
Submitted: 2002-05-22 09:31 UTC Modified: 2002-05-23 09:24 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: kaz at telemedia dot hu Assigned:
Status: Not a bug Package: Output Control
PHP Version: 4.1.2 OS: unix
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kaz at telemedia dot hu
New email:
PHP Version: OS:

 

 [2002-05-22 09:31 UTC] kaz at telemedia dot hu
source code at http://localhost/talalka.php :


<?php
  header("Content-type: text/plain");
  echo "LOFASZ\n";
?>


command running:


/usr/bin/lynx -source -mime_header http://localhost/talalka.php


result:


HTTP/1.1 200 OK
Date: Wed, 22 May 2002 13:24:29 GMT
Server: Apache/1.3.22 (Unix) PHP/4.1.2
X-Powered-By: PHP/4.1.2
Connection: close
Content-Type: text/plain

LOFASZ


As you can see, php sends wrong header. The "Content-type" header is not sent as i wrote it into the header function, and this causes chaos, because as the cgi specification, this header is case sensitive and has to be written as "Content-type".

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-22 14:28 UTC] sniper@php.net
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17

Where does it say that these are case-sensitive?


 [2002-05-23 04:29 UTC] kaz at telemedia dot hu
ok, start it again.

source code at http://localhost/talalka.php :

<?php
  header("Content-type: text/plain");
  echo "LOFASZ\n";
?>

command running:

/usr/bin/lynx -source -mime_header http://localhost/talalka.php

result:

HTTP/1.1 200 OK
Date: Wed, 22 May 2002 13:24:29 GMT
Server: Apache/1.3.22 (Unix) PHP/4.1.2
X-Powered-By: PHP/4.1.2
Connection: close
Content-Type: text/plain

LOFASZ

As you can see, php sends wrong header. The "Content-type" header is not
sent as i wrote it into the header function, and this causes chaos.

Right?.
 [2002-05-23 05:55 UTC] hholzgra@php.net
#1 HTTP headers are defined as Case-Insensitive. period.

#2 CGI does not specify headers at all

#3 this is not a PHP issue, PHP passes the content-type
   to apache, it is the apache web server that treats the
   content-type header special and writes the Content-Type:
   part of the header line in this case
   this will happen to every Content-Type header set by
   an apache module, it will not happen for CGIs

   you can verify this by using the PHP command line 
   interface (CLI):

   echo "<?php header('Content-type: text/plain'); ?>" | php

   result:

   X-Powered-By: PHP/4.2.0
   Content-type: text/plain

 [2002-05-23 06:24 UTC] kaz at telemedia dot hu
ok, sorry, forwarding this to the apache group.
 [2002-05-23 08:39 UTC] hholzgra@php.net
good luck ;)

again: apache does nothing wrong here,
       as HTTP headers are defined as case insensitive
        
       whatever "causes chaos" for you is something that
       is *not* HTTP complient, so you should try to 
       get that fixed instead of blaming software that
       is perfectly compliant, although maybe in a way
       you didn't expect ...


please read the HTTP specs

RRF2616, 4.2 Message Headers: "... Field names are case-insensitive. ..."
(http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2)

RFC2616, 14.17 Content-Type
       Content-Type   = "Content-Type" ":" media-type



 [2002-05-23 09:10 UTC] kaz at telemedia dot hu
oh, man, would you please concentrate to the problem??

i'm running a command which puts out a header. 
i'm giving this command a parameter, the text of the header.
this text is: "Content-type: text/plain"
this is case sensitive, because i want this header, this text. not anything else.
and i get something completely different: Content-Type: text/plain
THIS is the problem aside from the specifications.
ok, the headers are case insensitive, but i want the header as i commanded the code to output it to me, not otherwise.
 [2002-05-23 09:24 UTC] hholzgra@php.net
have a look at the sapi_apache_header_handler() function

http://lxr.php.net/source/php4/sapi/apache/mod_php4.c#153

and especially line 170

http://lxr.php.net/source/php4/sapi/apache/mod_php4.c#170

thats how the content type is passed to apache: not as a complete header string but as the mime-type only in the content_type component of the requert_rec structure r

so there is no way for apache to know if you wrote
Content-Type, Content-type or even cOnTeNt-TYPE

and as it doesn't matter there is no chance that they
(the apache people) will change their APIs for you to
get case sensitive behaviour in a place that is NOT
to be meant case sensitive

on the other hand they could even decide to convert
*all* header field names to lowercase if they wanted

so i *am* concentrating on the real problem, trying
to convince you that relying on case sensitivity or
case preservation here is just plain wrong in the 
first place.
 [2002-05-23 09:29 UTC] kaz at telemedia dot hu
ok, thank you (all).
i'm forwarding this stuff to our developer, he said to me, that the headers are case sensitive, and coded the application in wrong way.
thanks again.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 14:01:30 2024 UTC