INCUTIO HOME | SCRIPTS | CONTACT

HttpClient Demo

HttpClient Home | Download HttpClient (tar.gz) | HttpClient Manual | HttpClient Examples

This demo (which may take a few seconds to load) attempts to retrieves the front page of Amazon.com and reports its size in bytes. Debug mode is switched on to show what the script is doing. This demonstrates the script automatically following redirections and maintaining cookies and referrers between sessions.

$client = new HttpClient('www.amazon.com');
$client->setDebug(true);
if (!$client->get('/')) {
    echo '<p>Request failed!</p>';
} else {
    echo '<p>Amazon home page is '.strlen($client->getContent()).' bytes.</p>';
}
HttpClient Debug: Request
GET / HTTP/1.0
Host: www.amazon.com
User-Agent: Incutio HttpClient v0.9
Accept: text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,image/jpeg,image/gif,*/*
Accept-encoding: gzip
Accept-language: en-us

HttpClient Debug: HTTP/1.1 200 OK
HttpClient Debug: Received Headers
Array
(
    [date] => Sun, 21 Mar 2010 04:04:26 GMT
    [server] => Server
    [set-cookie] => Array
        (
            [0] => skin=noskin; path=/; domain=.amazon.com; expires=Sun, 21-Mar-2010 04:04:26 GMT
            [1] => session-id-time=1269673200l; path=/; domain=.amazon.com; expires=Sat Mar 27 07:00:00 2010 GMT
            [2] => session-id=191-5646035-3420043; path=/; domain=.amazon.com; expires=Sat Mar 27 07:00:00 2010 GMT
        )

    [x-amz-id-1] => 006GEJAXVEW0VNA4479E
    [p3p] => policyref="http://www.amazon.com/w3c/p3p.xml",CP="AMZN "
    [x-amz-id-2] => grlnOk71wzWoKQrhF0prTe1GaOQdtdaA
    [vary] => Accept-Encoding,User-Agent
    [content-encoding] => gzip
    [content-type] => text/html; charset=ISO-8859-1
    [connection] => close
)
HttpClient Debug: Content is gzip encoded, unzipping it
HttpClient Debug: Persisting referer: http://www.amazon.com/

Amazon home page is 122436 bytes

scripts.incutio.com light logo