Custom Headers
The setHeaders method is the Swiss Army Knife of header management for Zend_Http_Client. See the example below for the multitude of ways in which headers can be set.
<?php
// Single header, with header name and value separate $client->setHeaders('Host', 'localhost.example');
// Single header, with header name and value together $client->setHeaders('Host: localhost.example');
// Single header with multiple values, mainly useful for cookies $client->setHeaders('Cookie', array(
'lang=en-US',
'PHPSESSID=1a0b82148815944c548caef5ccb884c9'
));
// Multiple headers, with header names and values separate $client->setHeaders(array(
'Host' => 'localhost.example',
'User-Agent' => 'Zend_Http_Client 1.7.2'
));
// Multiple headers, with header names and values together $client->setHeaders(array(
'Host: localhost.example',
'User-Agent: Zend_Http_Client 1.7.2'
));
?>
© Zend_Http_Client — Web Scraping >>> Back to TABLE OF CONTENTS <<< | |
| Views: 424 | |
| Total comments: 0 | |