Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:36692 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2397 invoked from network); 30 Mar 2008 21:05:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Mar 2008 21:05:55 -0000 Authentication-Results: pb1.pair.com header.from=sam@sambarrow.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=sam@sambarrow.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain sambarrow.com from 208.70.128.77 cause and error) X-PHP-List-Original-Sender: sam@sambarrow.com X-Host-Fingerprint: 208.70.128.77 smtp-gw51.mailanyone.net Received: from [208.70.128.77] ([208.70.128.77:32947] helo=smtp-gw51.mailanyone.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D1/A3-12628-0B000F74 for ; Sun, 30 Mar 2008 16:05:54 -0500 Received: from mailanyone.net by smtp-gw51.mailanyone.net with esmtpsa (TLSv1:AES256-SHA:256) (MailAnyone extSMTP sam@sambarrow.com) id 1Jg4is-00044V-5W; Sun, 30 Mar 2008 16:05:50 -0500 To: "Edward Z. Yang" Cc: internals@lists.php.net In-Reply-To: References: <47EC2065.2000002@peytz.dk> Content-Type: text/plain Date: Sun, 30 Mar 2008 17:05:51 -0400 Message-ID: <1206911151.14203.5.camel@sams-room.local> Mime-Version: 1.0 X-Mailer: Evolution 2.12.1 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: [PATCH] Allow unsetting headers previously set by header() From: sam@sambarrow.com (Sam Barrow) On Sun, 2008-03-30 at 16:05 -0400, Edward Z. Yang wrote: > Christian Schmidt wrote: > > What do you think of the general idea of being able to unset > headers? > > And what do you think of my patch? > > If you need this kind of flexibility, I recommend you make an > HttpHeaders class which manages these things and then sends them when > necessary. > That's what I do. All you need is some simple functions: $headers = array(); addHeader($name, $value) { global $headers; $headers[$name] = $value; return true; } deleteHeader($name) { global $headers; if (array_key_exists($name, $headers)) { unset($headers[$name]); } return true; } sendHeaders() { global $headers; foreach ($headers as $name => $value) { header($name . ': ' . $value); } return true; }