php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #19778 Provide a way to remove http headers - like f.x. header("Pragma:")
Submitted: 2002-10-06 08:29 UTC Modified: 2008-11-13 16:00 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: php at savignano dot de Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.2.1 OS: any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: php at savignano dot de
New email:
PHP Version: OS:

 

 [2002-10-06 08:29 UTC] php at savignano dot de
Sometimes it would be very handy to be able to remove a http header that has already been set (for example, by the session module). Even though header() allows me to replace a header, there is no way to completely remove it.

Proposal: 
header("Pragma:") could be used to remove a Pragma header - i.e. a header given with no parms would remove the header.

Better:
New function like remove_header()

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-11-10 18:41 UTC] maxim@php.net
Blind shot - this is impossible because headers get sent as soon I they are encountered and thus you can override them by sending one more yet cannot remove what you have already sent. I might be wrong, though.

If I'm not then lots close this one. 
 [2002-11-11 15:02 UTC] php at savignano dot de
If you can <i>modify</i> headers using the header() function, they can't be sent already, can they?

At least with some types of headers, this works.

So I assume that headers are buffered at least until the document output has begun.
 [2003-06-13 08:06 UTC] Xuefer at 21cn dot com
in php manual:
> The optional replace parameter indicates
> whether the header should replace a previous similar
> header,
> or add a second header of the same type.
> By default it will replace, but if you
> pass in FALSE as the second argument you can force
> multiple headers of the same type

so it can "replace" header, is should be able to "unset" header

header() is to "low level"
better to implement these functions:
header_set($name, $value [, response_code]) // replace or set new one
header_add($name, $value) // "append" new one
header_unset($name, [, $count]) // remove all, or N

these functions will work, until header_sent(), after which will get warnning.

it's just like operating on an array/table (but allow dup key)
 [2003-06-13 08:13 UTC] Xuefer at 21cn dot com
by the way
php document never said: "headers get sent as soon they are encountered"

and it seems different for each sapi module

it's better for php to buffer all response headers until give it to sapi
and use:
header_flush();
to flush headers, but keep header_sent() false, which meaning header is not ended yet
header_flush is only used to "ping" client to see if connection lost, before output any content.

u may say, i can buffer it in script using array, but this is not able to manage php's internal headers
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 07 15:01:36 2024 UTC