Re: [PATCH] Add HTTP Status Code Functions to PEAR::HTTP
| From: | Arnaud Limbourg | Date: | Thu, 20 Nov 2003 06:59:49 +0000 |
| Subject: | Re: [PATCH] Add HTTP Status Code Functions to PEAR::HTTP | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-23757@lists.php.net to get a copy of this message | ||
Hi davey,
It would make sense indeed to add them HTTP. I could use that ;)
Arnaud.
Davey wrote:
Dear All, Please find here[1] a patch to add the following methods to PEAR::HTTP HTTP::statusType - Type of statusCode (as defined in the RFC) HTTP::statusText - The Message for the error code (from RFC) HTTP::isInformational - Is an Informational code (1xx code) HTTP::isSuccessful - Is a Success code (2xx code) HTTP::isRedirect - Is a Redirect code (3xx code) HTTP::isClientError - Is a Client Error code (4xx code) HTTP::isServerError - Is a Server Error code (5xx code) HTTP::isError - Is a Client OR Server Error code (4xx or 5xx code) All of these take a HTTP status code as their one and only argument. There is one pitfall, the HTTP::is* methods use HTTP::statusType, now, if HTTP::statusType returns a FALSE (i.e. status code not found), so will the HTTP::is* method... this could cause problems, though it shouldn't do. These methods are much needed in PEAR, unless I have missed them somewhere. I don't see any point in creating a sepearate HTTP::Status package or some such, HTTP is quite empty and these can be used by any packages in the HTTP (or Net) catagories to check status codes. Might be wise to rename statusText to statusMessage, thoughts? Just for anyone who's interested, I tried to implement the HTTP::statusType method using bitmasks, but there is just too many status types, I ran into an overflow at the 412/413 code (IIRC). Anyways, comments welcome. If nobody objects by sunday I'll commit... two weekdays and the weekend is surely enough. - Davey [1] http://pixelated-dreams.com/~davey/misc/HTTP.diff