HttpRequest::setHeaders
(PECL pecl_http >= 0.12.0)
HttpRequest::setHeaders — Set headers
Описание
public
bool HttpRequest::setHeaders
([ array
$headers
] )Set request header name/value pairs.
Список параметров
-
headers
-
an associative array as parameter containing header name/value pairs; if empty or omitted, all previously set headers will be unset
Возвращаемые значения
Возвращает TRUE
в случае успешного завершения или FALSE
в случае возникновения ошибки.
[an error occurred while processing the directive]
- Функция HttpRequest::addCookies() - Add cookies
- Функция HttpRequest::addHeaders() - Add headers
- Функция HttpRequest::addPostFields() - Add post fields
- Функция HttpRequest::addPostFile() - Add post file
- Функция HttpRequest::addPutData() - Add put data
- Функция HttpRequest::addQueryData() - Add query data
- Функция HttpRequest::addRawPostData() - Add raw post data
- Функция HttpRequest::addSslOptions() - Add ssl options
- Функция HttpRequest::clearHistory() - Clear history
- Функция HttpRequest::__construct() - HttpRequest constructor
- Функция HttpRequest::enableCookies() - Enable cookies
- Функция HttpRequest::getContentType() - Get content type
- Функция HttpRequest::getCookies() - Get cookies
- Функция HttpRequest::getHeaders() - Get headers
- Функция HttpRequest::getHistory() - Get history
- Функция HttpRequest::getMethod() - Get method
- Функция HttpRequest::getOptions() - Get options
- Функция HttpRequest::getPostFields() - Get post fields
- Функция HttpRequest::getPostFiles() - Get post files
- Функция HttpRequest::getPutData() - Get put data
- Функция HttpRequest::getPutFile() - Get put file
- Функция HttpRequest::getQueryData() - Get query data
- Функция HttpRequest::getRawPostData() - Get raw post data
- Функция HttpRequest::getRawRequestMessage() - Get raw request message
- Функция HttpRequest::getRawResponseMessage() - Get raw response message
- Функция HttpRequest::getRequestMessage() - Get request message
- Функция HttpRequest::getResponseBody() - Get response body
- Функция HttpRequest::getResponseCode() - Get response code
- Функция HttpRequest::getResponseCookies() - Get response cookie(s)
- Функция HttpRequest::getResponseData() - Get response data
- Функция HttpRequest::getResponseHeader() - Get response header(s)
- Функция HttpRequest::getResponseInfo() - Get response info
- Функция HttpRequest::getResponseMessage() - Get response message
- Функция HttpRequest::getResponseStatus() - Get response status
- Функция HttpRequest::getSslOptions() - Get ssl options
- Функция HttpRequest::getUrl() - Get url
- Функция HttpRequest::resetCookies() - Reset cookies
- Функция HttpRequest::send() - Send request
- Функция HttpRequest::setBody() - Set request body to send, overwriting previously set request body.
- Функция HttpRequest::setContentType() - Set content type
- Функция HttpRequest::setCookies() - Set cookies
- Функция HttpRequest::setHeaders() - Set headers
- Функция HttpRequest::setMethod() - Set method
- Функция HttpRequest::setOptions() - Set options
- Функция HttpRequest::setPostFields() - Set post fields
- Функция HttpRequest::setPostFiles() - Set post files
- Функция HttpRequest::setPutData() - Set put data
- Функция HttpRequest::setPutFile() - Set put file
- Функция HttpRequest::setQueryData() - Set query data
- Функция HttpRequest::setRawPostData() - Set raw post data
- Функция HttpRequest::setSslOptions() - Set ssl options
- Функция HttpRequest::setUrl() - Set URL
Коментарии
note: you should not put a colon in the keys of the arrays you pass this method, it will do that for you. and if you do put colons in the array keys, the resultant headers will have 2 colons beside one another.
so for example,
<?php
$httpRequest->setHeaders(array('User-Agent' => 'Mozilla/1.22 (compatible; MSIE 5.01; PalmOS 3.0) EudoraWeb 2'));
?>
will result in
User-Agent: Mozilla/1.22 (compatible; MSIE 5.01; PalmOS 3.0) EudoraWeb 2
<?php
$httpRequest->setHeaders(array('User-Agent:' => 'Mozilla/1.22 (compatible; MSIE 5.01; PalmOS 3.0) EudoraWeb 2'));
?>
will result in
User-Agent:: Mozilla/1.22 (compatible; MSIE 5.01; PalmOS 3.0) EudoraWeb 2