I prepared and published a package that helps me writing complex scripts with HTTP request/response.
You can get it from my site (gCurl.tar.bz2)
or from PHP Clases when it will get published.
I used it to handle HTTP requests/responses in a number of projects, like "PHP Server-side browser", "Craigslist submitter", in spiders and crawlers, and now it will be a part of my Mirrors project.
Now I updated it for PHP 5.2, commented generously and added a number of samples of usage.
Briefly, the package implements commonly used routines of preparing HTTP requests and parsing server response.
For request it provides means to send cookies, custom headers, GET parameters and POST data.
Response processing includes processing HTTP headers, including multi-line headers, cookies parsing ( representing them as an array convenient to work with ).
The most powerful important feature of the package is an interface that helps assigning handlers for response headers and body.
Assigning a handler for a response body allows processing the data on-the-fly, by chunks, as received from the server.
This way one can process HTTP response body without waiting for all data to be received and not consuming memory for the whole response body.
Most important, one can assign the body handler after processing response headers. This allows assigning a handler depending on Content-Type or cookie.
This allows me to write very flexible scripts dealing with HTTP.
Hope it will help you as well :)
3 comments:
Are you available to help me install memcache on a production server?
I am looking for someone to help today?
I am trying to post data to a craigslist form and receive the result using curl but I keep being redirected back to the form. I am captuign all the form input names and value and sending them in the post, but I keep being redirected back, any tips?
merovinq...AT..gmail.com
I am trying to post data to a craigslist form and receive the result using curl but I keep being redirected back to the form. I am captuign all the form input names and value and sending them in the post, but I keep being redirected back, any tips?
merovinq...AT..gmail.com
Post a Comment