本文整理汇总了PHP中SimpleHttpRequest::addHeaderLine方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleHttpRequest::addHeaderLine方法的具体用法?PHP SimpleHttpRequest::addHeaderLine怎么用?PHP SimpleHttpRequest::addHeaderLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleHttpRequest
的用法示例。
在下文中一共展示了SimpleHttpRequest::addHeaderLine方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addAdditionalHeaders
/**
* Adds additional manual headers.
* @param SimpleHttpRequest $request Outgoing request.
* @access private
*/
protected function addAdditionalHeaders(&$request)
{
foreach ($this->additional_headers as $header) {
$request->addHeaderLine($header);
}
}
示例2: addBasicHeaders
/**
* Presents the appropriate headers for this
* location for basic authentication.
* @param SimpleHttpRequest $request Request to modify.
* @param string $username Username for realm.
* @param string $password Password for realm.
* @access public
*/
static function addBasicHeaders($request, $username, $password)
{
if ($username && $password) {
$request->addHeaderLine('Authorization: Basic ' . base64_encode("{$username}:{$password}"));
}
}
示例3: testWritingAdditionalHeaders
public function testWritingAdditionalHeaders()
{
$socket = new MockSimpleSocket();
$socket->expectAt(0, 'write', array("My: stuff\r\n"));
$socket->expectAt(1, 'write', array("\r\n"));
$socket->expectCallCount('write', 2);
$route = new MockSimpleRoute();
$route->setReturnReference('createConnection', $socket);
$request = new SimpleHttpRequest($route, new SimpleGetEncoding());
$request->addHeaderLine('My: stuff');
$request->fetch(15);
}
示例4: foreach
/**
* Adds additional manual headers.
* @param SimpleHttpRequest $request Outgoing request.
* @access private
*/
function _addAdditionalHeaders($request)
{
foreach ($this->_additional_headers as $header) {
$request->addHeaderLine($header);
}
}
示例5: addBasicHeaders
/**
* Presents the appropriate headers for this
* location for basic authentication.
* @param SimpleHttpRequest $request Request to modify.
* @param string $username Username for realm.
* @param string $password Password for realm.
* @access public
* @static
*/
function addBasicHeaders(&$request, $username, $password) {
if ($username && $password) {
$request->addHeaderLine(
'Authorization: Basic ' . base64_encode("$username:$password"));
}
}
示例6: testWritingAdditionalHeaders
function testWritingAdditionalHeaders()
{
$request = new SimpleHttpRequest("http://a.valid.host/and/path");
$request->addHeaderLine("My: stuff");
$socket =& new MockSimpleSocket($this);
$socket->setReturnValue("isError", false);
$socket->expectArgumentsSequence(0, "write", array("GET /and/path HTTP/1.0\r\n"));
$socket->expectArgumentsSequence(1, "write", array("Host: a.valid.host\r\n"));
$socket->expectArgumentsSequence(2, "write", array("My: stuff\r\n"));
$socket->expectArgumentsSequence(3, "write", array("Connection: close\r\n"));
$socket->expectArgumentsSequence(4, "write", array("\r\n"));
$socket->expectCallCount("write", 5);
$request->fetch($socket);
$socket->tally();
}