本文整理匯總了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();
}