HttpRequest
在线手册:中文 英文
PHP手册

HttpRequest::addHeaders

(PECL pecl_http >= 0.10.0)

HttpRequest::addHeadersAdd headers

说明

public bool HttpRequest::addHeaders ( array $headers )

Add request header name/value pairs.

参数

headers

an associative array as parameter containing additional header name/value pairs

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE.


HttpRequest
在线手册:中文 英文
PHP手册
PHP手册 - N: Add headers

用户评论:

pal (04-Nov-2008 12:20)

If like me you were wondering why your POST request is going out with the header 'Expect: 100-continue' set, it is being added by libcurl.

This can only be noticed when using HttpRequest::getRawRequestMessage() and not HttpRequest::getHeaders(), or of course tcpdump or similar.

To remove this header you can do the following;

$r->addHeaders(array('Expect' => ''));

Note this behaviour has also been reported in http://au.php.net/manual/en/function.curl-setopt.php#82418