PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTTP » HTTP_Header » Bug #5404

Headers cannot be unset

Details

Submitted2005-09-14 21:14 UTC
Fromgugglegum at gmail dot com
Assignedmike
StatusClosed
PackageHTTP_Header
PHP VersionIrrelevant
OSIrrelevant
Roadmaps(Not assigned)

Comments

[2005-09-14 21:14 UTC] gugglegum at gmail dot com

Description:
------------
HTTP_Header class declares property $_headers, which initially contains several headers, that are sent by default (you say). This is wrong. At least at my side, PHP does not send any headers that prevent caching. In order to prove it, this is HTTP request made by terminal (manually) to empty PHP-script (script that contains only <?php ?>):

--------------------------------------
GET /test.php HTTP/1.1
Host: paul.jetstyle.ru

HTTP/1.1 200 OK
Date: Wed, 14 Sep 2005 20:58:25 GMT
Server: Apache/1.3.33 (Win32) PHP/5.0.5
X-Powered-By: PHP/5.0.5
Transfer-Encoding: chunked
Content-Type: text/html

0
--------------------------------------
As you can see here - there are no Pragma and Cache-Control headers. Though maybe it really was in past.

My task is to allow clients to cache pages - I'm sending correct Last-Modified header and handle If-Modified-Since http-request header. So, your "Pragma: no-cache" and "Cache-Control: no-store, no-cache, ..." Is a trouble for me. This trouble can be workarounded by resetting these headers but, there is no any way to remove previously assigned header. I do:

$httpHeaders->setHeader('pragma', null);
$httpHeaders->setHeader('cache-control', null);

It works, but these headers still sends empty:

--------------------------------------
GET / HTTP/1.1
Host: www.avtoprokat-ekb.ru

HTTP/1.1 200 OK
Date: Wed, 14 Sep 2005 21:05:04 GMT
Server: Apache/1.3.33 (Win32) PHP/5.0.5
X-Powered-By: PHP/5.0.5
pragma:
cache-control:
last-modified: Wed, 14 Sep 2005 19:40:40 GMT
Transfer-Encoding: chunked
Content-Type: text/html; charset=windows-1251
--------------------------------------

I think this is unpretty.

My suggestion is to keep initially empty $_headers property and add modify setHeader() method, which remove header if it new value === null (not "" or 0).

[2005-09-14 21:31 UTC] gugglegum at gmail dot com

I have modified this class for instant needs. You can get my modified version at http://paul.jetstyle.ru/temp/Header.phps

[2005-09-15 07:17 UTC] gugglegum at gmail dot com

Yes, thank you.