Re: [PATCH] Fixes + Add HTTP Status Handlers to HTTP_Header

From: Date: Mon, 01 Dec 2003 20:41:14 +0000
Subject: Re: [PATCH] Fixes + Add HTTP Status Handlers to HTTP_Header
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-24023@lists.php.net to get a copy of this message
thanks. i am patching the source ... wolfram Davey wrote:
Hey, After patching HTTP, it now seems that HTTP_Header should contain my HTTP Status stuff. I've added this, and made some changes to HTTP_Headers code to (IMO) better it. One of the changes I made was the following:
        if ( is_int($code) ) {
            // if the $code is an int we get the constant here
            // is there an easier way to build a constant dynamically?
            eval("\$code = HTTP_HEADER_STATUS_".$code.';');
        }
becomes:
    if (defined('HTTP_HEADER_STATUS_' .$code)) {
            $status_msg = constant('HTTP_HEADER_STATUS_' .$code);
            header( 'HTTP/'.$this->_httpVersion. ' ' .$code. ' '      .$status_msg);
        }
The use of constant() is far better than using eval() :) Also, I removed the numbers in the constants values, this is for my statusText() method, however, I did make changes to the places they were needed to make sure the number is included in the header() call. One final thing, I removed the require_once for PEAR.php, I see no need for it at all. You can find the patch here [1] and a test here [2] I hope all is satisfactory - Davey [1] http://davey.is-a-geek.com/php-cvs/diffs/PEAR/HTTP_Header.txt [2] http://davey.is-a-geek.com/test/HTTP_test.php
-- Wolfram http://opensource.visionp.de ... authentication system .... http://sf.net/projects/auth

« previous php.pear.dev (#24023) next »