Package idea: HTTP::SimpleClient
| From: | Alexey Borzov | Date: | Sun, 16 Mar 2003 11:43:57 +0000 |
| Subject: | Package idea: HTTP::SimpleClient | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-14326@lists.php.net to get a copy of this message | ||
Greetings!
I've used HTTP::Request for some time and it occured to me that most of the time a more high-level interface to HTTP that wraps around HTTP::Request is in fact needed. Consider the Snoopy package for example of such a high level interface: http://snoopy.sourceforge.net/
I even made such a class for my application, and while it is itself too application-specific, there are parts that are quite generic and can be extracted into a separate class.
The HTTP::SimpleClient class should probably have the following functionality:
head($url) - perform a HEAD request on $url
get($url, $params) - perform a GET request on $url, optionally adding $params to it (consider a <form method="get">)
post($url, $params) - perform a POST request on $url
It should also manage cookies between requests. This functionality is ready, the class that implements it is a pretty generic one and the only problem with it are the comments in Russian -- I misplaced the variant with English ones. :[
There should be a possibility to set default parameters/headers for requests.
The class should manage redirects (cookie management, referrers, all this stuff).
Response processing itself should be left out of the class (unlike Snoopy). There should be a possibility to check the response for some tokens indicating success/failure (not a HTTP kind of failure but "please fill all the form fields" one) and to apply callback functions in case of success, for example:
1. form submitted ok, save received ID and password;
2. GET request was OK, now extract the links and continue crawling the site.