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 301 Moved Permanently
HttpClient Debug: Received Headers
Array
(
    [server] => CloudFront
    [date] => Sun, 22 Oct 2017 22:28:19 GMT
    [content-type] => text/html
    [content-length] => 183
    [connection] => close
    [location] => https://www.amazon.com/
    [x-cache] => Redirect from cloudfront
    [via] => 1.1 f7c2c81dcd8f9c4723ba9992c4abd851.cloudfront.net (CloudFront)
    [x-amz-cf-id] => g4BRWWk7k38xzFgCmAGBpYV4cSf59ULQADQomtOpxcJuqXu1wNSZ3w==
)
HttpClient Debug: Persisting referer: http://www.amazon.com/
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
Referer: http://www.amazon.com/

HttpClient Debug: HTTP/1.1 301 Moved Permanently
HttpClient Debug: Received Headers
Array
(
    [server] => CloudFront
    [date] => Sun, 22 Oct 2017 22:28:19 GMT
    [content-type] => text/html
    [content-length] => 183
    [connection] => close
    [location] => https://www.amazon.com/
    [x-cache] => Redirect from cloudfront
    [via] => 1.1 a167cf4c8e9c4bb7e043c4a833f14587.cloudfront.net (CloudFront)
    [x-amz-cf-id] => 4T4bFOEV62L4Hnj91IqZgj4-0ntmeK1muRIZqhsMZ8MKrnaL6UEV0w==
)
HttpClient Debug: Persisting referer: http://www.amazon.com/
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
Referer: http://www.amazon.com/

HttpClient Debug: HTTP/1.0 301 Moved Permanently
HttpClient Debug: Received Headers
Array
(
    [server] => AkamaiGHost
    [content-length] => 0
    [location] => https://www.amazon.com/
    [date] => Sun, 22 Oct 2017 22:28:19 GMT
    [connection] => close
)
HttpClient Debug: Persisting referer: http://www.amazon.com/
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
Referer: http://www.amazon.com/

HttpClient Debug: HTTP/1.1 301 Moved Permanently
HttpClient Debug: Received Headers
Array
(
    [server] => CloudFront
    [date] => Sun, 22 Oct 2017 22:28:19 GMT
    [content-type] => text/html
    [content-length] => 183
    [connection] => close
    [location] => https://www.amazon.com/
    [x-cache] => Redirect from cloudfront
    [via] => 1.1 bc30b374b64a194ed68c5b62e617bac6.cloudfront.net (CloudFront)
    [x-amz-cf-id] => QbLB8eLBUjpRlSed-_Ueutd-xAfDGwvrmqFPgYDqXXl4GSa_dOR_EQ==
)
HttpClient Debug: Persisting referer: http://www.amazon.com/
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
Referer: http://www.amazon.com/

HttpClient Debug: HTTP/1.1 301 Moved Permanently
HttpClient Debug: Received Headers
Array
(
    [server] => CloudFront
    [date] => Sun, 22 Oct 2017 22:28:19 GMT
    [content-type] => text/html
    [content-length] => 183
    [connection] => close
    [location] => https://www.amazon.com/
    [x-cache] => Redirect from cloudfront
    [via] => 1.1 69c4fecf3b313b4bea721d0c08afc356.cloudfront.net (CloudFront)
    [x-amz-cf-id] => AvKcKCawKDTn15aymnntPkomZIq7e4WI7a053Kq3fhvZYTkoggHrCA==
)
HttpClient Debug: Persisting referer: http://www.amazon.com/
HttpClient Debug: Number of redirects exceeded maximum (5)

Request failed!

scripts.incutio.com light logo