本文整理匯總了PHP中Buzz\Browser::getLastRequest方法的典型用法代碼示例。如果您正苦於以下問題:PHP Browser::getLastRequest方法的具體用法?PHP Browser::getLastRequest怎麽用?PHP Browser::getLastRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Buzz\Browser
的用法示例。
在下文中一共展示了Browser::getLastRequest方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getLastRequest
public function getLastRequest()
{
if ($this->fromCache) {
return $this->data['request'];
}
return parent::getLastRequest();
}
示例2: echoLastRequest
/**
* @Then /^echo last request$/
*
* Echos the last request for debugging purposes
* -
* Example:
* And echo last request
*/
public function echoLastRequest()
{
$request = $this->client->getLastRequest();
echo sprintf("%s %s%s HTTP/%s\n", $request->getMethod(), $request->getHost(), $request->getResource(), $request->getProtocolVersion());
$headerString = '';
foreach ($request->getHeaders() as $header) {
$headerString = sprintf("%s%s\n", $headerString, $header);
}
echo rtrim($headerString, "\n");
if (empty($request->getContent()) === false) {
echo sprintf("\nContent: %s", $request->getContent());
}
}
示例3: echoLastResponse
/**
* @Then /^echo last response$/
* @return void
*/
public function echoLastResponse()
{
$this->printDebug($this->client->getLastRequest() . "\n\n" . $this->response . "\n\n" . "access_token: " . $this->access_token);
}
示例4: fromUrl
/**
* Parse an url address, and fill up the basic metadata.
*
* @param string $url
* @param \Buzz\Client\ClientInterface $client
* @return \Yoozi\Miner\Extractor
*/
public function fromUrl($url, HttpClientInterface $client = null)
{
$browser = new Browser($client);
$response = $browser->get($url, $this->config->get('headers'));
$request = $browser->getLastRequest();
$this->metadata = array();
foreach (array('url', 'host', 'domain', 'favicon') as $key) {
$this->metadata[$key] = $this->{'get' . studly_case($key)}($request);
}
if ($response->isSuccessful()) {
$this->document = $response->getContent();
$this->charset = $response->getHeaderAttribute('Content-Type', 'charset');
}
return $this;
}