Re: Package proposal: HTTP_Status
| From: | Alexey Borzov | Date: | Tue, 26 Aug 2003 10:52:46 +0000 |
| Subject: | Re: Package proposal: HTTP_Status | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-20542@lists.php.net to get a copy of this message | ||
Marshall Roch wrote:
I've created a class called HTTP_Status that translates HTTP (including WebDAV) status codes (e.g. 200, 404, 304) into human-readable form (respectively "OK", "Not Found", "Not Modified"). It also has methods to check whether a given status code is "informational," "success," "redirection," "client error," or "server error." There are a number of classes already in PEAR that could make use of this.-1 for the standalone package. I don't quite see the problem it is trying to solve. 1) Mapping from response codes to their meanings can easily be done via an array. 2) Getting the type of response can be done via switch(intval($code / 100)) {
case 1:
...
case 2:
$type = 'Success';
break;
case 3:
...
case 4:
...
}
and caring about special cases.
In HTTP_Client, the following is used to check for redirection: if ( ... in_array($code, array(300, 301, 302, 303, 307))) {It wouldn't be, as 304 is not exactly a redirect and 306 is unused. You are actually proposing an inferior solution.... do stuff because it's a redirection ...} With HTTP_Status, it would be: if ( ... HTTP_Status::isRedirection($code)) {... do stuff because it's a redirection ...}