本文整理匯總了PHP中SimpleHttpRequest::setCookie方法的典型用法代碼示例。如果您正苦於以下問題:PHP SimpleHttpRequest::setCookie方法的具體用法?PHP SimpleHttpRequest::setCookie怎麽用?PHP SimpleHttpRequest::setCookie使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SimpleHttpRequest
的用法示例。
在下文中一共展示了SimpleHttpRequest::setCookie方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testHttp
function testHttp()
{
$http = new SimpleHttpRequest("www.lastcraft.com/test/network_confirm.php?gkey=gvalue");
$http->setCookie(new SimpleCookie("ckey", "cvalue"));
$this->assertIsA($reponse = $http->fetch(), "SimpleHttpResponse");
$this->assertEqual($reponse->getResponseCode(), 200);
$this->assertEqual($reponse->getMimeType(), "text/html");
$this->assertWantedPattern('/A target for the SimpleTest test suite/', $reponse->getContent());
$this->assertWantedPattern('/gkey=gvalue/', $reponse->getContent());
$this->assertWantedPattern('/ckey=cvalue/', $reponse->getContent());
}
示例2: addHeaders
/**
* Adds the current cookies to a request.
* @param SimpleHttpRequest $request Request to modify.
* @param SimpleUrl $url Cookie selector.
* @access private
*/
function addHeaders(&$request, $url)
{
$cookies = $this->getValidCookies($url->getHost(), $url->getPath());
foreach ($cookies as $cookie) {
$request->setCookie($cookie);
}
}
示例3: fetchUrl
/**
* Fetches a URL performing the standard tests.
* @param $url Target to fetch as string.
* @param $request Test version of SimpleHttpRequest.
* @return Content of page.
* @access public
*/
function fetchUrl($url, $request = false)
{
if (!is_object($request)) {
$request = new SimpleHttpRequest($url);
}
foreach ($this->_cookie_jar->getValidCookies() as $cookie) {
$request->setCookie($cookie);
}
$this->_response = $request->fetch();
$this->_checkExpectations($url, $this->_response);
foreach ($this->_response->getNewCookies() as $cookie) {
$parsed_url = new SimpleUrl($url);
if ($parsed_url->getHost()) {
$cookie->setHost($parsed_url->getHost());
}
$this->_cookie_jar->setCookie($cookie);
}
return $this->_response->getContent();
}
示例4: testMultipleCookieWriting
function testMultipleCookieWriting()
{
$request = new SimpleHttpRequest("a.valid.host/and/path");
$request->setCookie(new SimpleCookie("a", "A"));
$request->setCookie(new SimpleCookie("b", "B"));
$socket =& new MockSimpleSocket($this);
$socket->setReturnValue("isError", false);
$socket->expectArgumentsSequence(2, "write", array("Cookie: a=A;b=B\r\n"));
$request->fetch($socket);
$socket->tally();
}