Re: Package proposal: HTTP_Status

From: Date: Tue, 26 Aug 2003 17:05:58 +0000
Subject: Re: Package proposal: HTTP_Status
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-20564@lists.php.net to get a copy of this message
Hi! Marshall Roch wrote:
-1 for the standalone package. I don't quite see the problem it is trying to solve.
It's trying to make it easier to translate status codes, and to check whether they're success, or errors, or whatever. It's also trying to put all of this information in one reusable place, so that updates to the protocols only require one code change.
OK, there are already HTTP and HTTP_Header packages: http://pear.php.net/package/HTTP http://pear.php.net/package/HTTP_Header What's the use of another package, that is a wrapper around an array and a bunch of number comparisons?
In HTTP_Client, the following is used to check for redirection: if ( ... in_array($code, array(300, 301, 302, 303, 307))) {
    ... do stuff because it's a redirection ...
}
[snip]
It wouldn't be, as 304 is not exactly a redirect and 306 is unused. You are actually proposing an inferior solution.
That's something you'd probably have to argue with the IETF about. All of the redirection codes[1] (including 304![2]) mean that another request needs to be initiated by the user agent.
OK, so if you think that there is a bug in HTTP_Client, file a bug report including a test case. Hint: no browser I know of "initiates another request" when receiving 304 and the spec defines only the cache's behaviour.
A conditional GET is the only case in which a 304 should be recieved; Since HTTP_Client isn't sending those, I don't think it's an issue.
It sends everything HTTP_Request is able to send, and HTTP_Request is quite capable of sending a conditional GET. ;]
If there are cases where you'd need exceptions, use: if (!in_array($code, array(304, 307)) && HTTP_Status::isRedirection($code)) {
    ...
}
You call *that* simplification? :] BTW, there is a genuine error in your class. Method isError() reads: function isError($code) {
    return ($this->is_error_server($code) || $this->is_error_client($code));
} while is_error_server() and is_error_client() are not defined.

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