03.02.2014 Views

php|architect's Guide to Web Scraping with PHP - Wind Business ...

php|architect's Guide to Web Scraping with PHP - Wind Business ...

php|architect's Guide to Web Scraping with PHP - Wind Business ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

54 ” pecl_http PECL Extension<br />

Debugging<br />

Debugging transmitted requests and responses <strong>with</strong> pecl_http is actually pretty<br />

simple. Configure and send a request, then call the getRawRequestMessage and<br />

getRawResponseMessage methods on the request instance as sho wn belo w .<br />

<br />

T imeouts<br />

As <strong>with</strong> cURL, pecl_http has options for handling timeouts.<br />

The ’timeout’ request option, which corresponds <strong>to</strong> CURLOPT_TIMEOUT, is the maximum<br />

number of seconds an entire request may take before timing out.<br />

Likewise the ’connecttimeout’ request option, the counterpart for<br />

CURLOPT_CONNECTTIMEOUT, is the maximum number of seconds that a connection<br />

attempt, which includes DNS resolution, may take.<br />

Finally the ’dns_cache_timeout’ request option, which is equivalent <strong>to</strong><br />

CURLOPT_DNS_CACHE_TIMEOUT, is the maximum number of seconds that a DNS<br />

cache entry will be retained and defaults <strong>to</strong> 120 seconds (two minutes).<br />

Content Encoding<br />

If you are unfamiliar <strong>with</strong> content encoding, see “ Content Encoding” in Chapter 8 for<br />

more information. To enable it when using pecl_http , the ’compress’ request option<br />

must be set <strong>to</strong> true.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!