本文整理汇总了PHP中Guzzle\Http\Message\Request::getMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getMethod方法的具体用法?PHP Request::getMethod怎么用?PHP Request::getMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guzzle\Http\Message\Request
的用法示例。
在下文中一共展示了Request::getMethod方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: printResult
public function printResult()
{
echo sprintf('%s %s : %s calls', strtoupper($this->request->getMethod()), $this->request->getUrl(), $this->nbCalls) . PHP_EOL;
foreach ($this->httpTimeDataCollector->getIterator() as $httpTimeResult) {
echo sprintf('total time = %s ms', $httpTimeResult) . PHP_EOL;
}
echo '--- statistics ---' . PHP_EOL;
echo sprintf('results filter on %s percentile', $this->httpTimeDataCollector->getPercentile()) . PHP_EOL;
echo sprintf('min/avg/max = %s/%s/%s ms', $this->httpTimeDataCollector->getMinTime(), $this->httpTimeDataCollector->getAverageTime(), $this->httpTimeDataCollector->getMaxTime()) . PHP_EOL;
}
示例2: addAuthenticationHeaders
/**
* Sign the current request for write operations
*
* @param Request $request The current request
*/
private function addAuthenticationHeaders(Request $request)
{
$client = $request->getClient();
// Get a GMT/UTC timestamp
$timestamp = gmdate('Y-m-d\\TH:i:s\\Z');
// Build the data to base the hash on
$data = $request->getMethod() . '|' . $request->getUrl() . '|' . $client->getConfig('publicKey') . '|' . $timestamp;
// Generate signature
$signature = hash_hmac('sha256', $data, $client->getConfig('privateKey'));
// Add relevant request headers (overwriting once that might already exist)
$request->setHeader('X-Imbo-Authenticate-Signature', $signature);
$request->setHeader('X-Imbo-Authenticate-Timestamp', $timestamp);
}
示例3: fromRequest
public function fromRequest(Request $request, $secretKey)
{
$method = strtolower($request->getMethod());
switch ($method) {
case 'post':
case 'patch':
case 'put':
case 'delete':
$body = (string) $request->getBody();
break;
default:
$body = $request->getQuery(true);
}
return $this->generate($body, $secretKey);
}
示例4: sendRequest
/**
* Function to send the request to the remote API
*
* @return \Trucker\Responses\Response
*/
public function sendRequest()
{
try {
$response = $this->request->send();
} catch (\Guzzle\Http\Exception\BadResponseException $e) {
$response = $e->getResponse();
}
if (Config::get('request.debug', false)) {
echo 'Request Method: ' . $this->request->getMethod() . "\n";
echo "Body: " . $response->getBody() . "\n";
echo "Status Code: " . $response->getStatusCode() . "\n";
echo "URL: " . $this->request->getUrl() . "\n\n";
}
return $this->app->make('trucker.response')->newInstance($this->app, $response);
}
示例5: signRequest
/**
* @param \Guzzle\Http\Message\Request $request
*/
public function signRequest(Request $request)
{
$url = $request->getPath();
if ('POST' == $request->getMethod() && $request instanceof EntityEnclosingRequest) {
$body = (string) $request->getBody();
$hash = $this->signature->generate($body);
} else {
$url .= '?' . $request->getQuery();
$hash = $this->signature->generate($url);
}
$request->addCookie('acquia_solr_time', $this->signature->getRequestTime());
$request->addCookie('acquia_solr_nonce', $this->signature->getNonce());
$request->addCookie('acquia_solr_hmac', $hash . ';');
// The timestamp should be current for each request.
$this->signature->unsetRequestTime();
}
示例6: send
private function send(Request $request)
{
try {
$this->logger and $this->logger->debug(sprintf('%s "%s"', $request->getMethod(), $request->getUrl()));
$this->logger and $this->logger->debug(sprintf("Request:\n%s", (string) $request));
$response = $this->client->send($request);
$this->logger and $this->logger->debug(sprintf("Response:\n%s", (string) $response));
return $response;
} catch (ClientErrorResponseException $e) {
$this->logException($e);
$statusCode = $e->getResponse()->getStatusCode();
$reasonPhrase = $e->getResponse()->getReasonPhrase();
$message = sprintf('The request is not valid (status code: "%d", reason phrase: "%s").', $statusCode, $reasonPhrase);
throw new ApiClientException($message, 0, $e);
} catch (BadResponseException $e) {
$this->logException($e);
throw new ApiServerException('Something went wrong with upstream.', 0, $e);
}
}
示例7: printLastResponseOnError
/**
* @AfterScenario
*/
public function printLastResponseOnError(BaseScenarioEvent $scenarioEvent)
{
if ($scenarioEvent->getResult() == StepEvent::FAILED) {
if ($this->response) {
$body = $this->getResponse()->getBody(true);
// could we even ask them if they want to print out the error?
// or do it based on verbosity
// print some debug details
$this->printDebug('');
$this->printDebug('<error>Failure!</error> when making the following request:');
$this->printDebug(sprintf('<comment>%s</comment>: <info>%s</info>', $this->lastRequest->getMethod(), $this->lastRequest->getUrl()) . "\n");
if ($this->response->isContentType('application/json') || $this->response->isContentType('+json')) {
$data = json_decode($body);
if ($data === null) {
// invalid JSON!
$this->printDebug($body);
} else {
// valid JSON, print it pretty
$this->printDebug(json_encode($data, JSON_PRETTY_PRINT));
}
} else {
// the response is HTML - see if we should print all of it or some of it
$isValidHtml = strpos($body, '</body>') !== false;
if ($this->useFancyExceptionReporting && $isValidHtml) {
$this->printDebug('<error>Failure!</error> Below is a summary of the HTML response from the server.');
// finds the h1 and h2 tags and prints them only
$crawler = new Crawler($body);
foreach ($crawler->filter('h1, h2')->extract(array('_text')) as $header) {
$this->printDebug(sprintf(' ' . $header));
}
} else {
$this->printDebug($body);
}
}
}
}
}
示例8: processSuccessfulRequest
/**
* @param Request $request
* @param string $body
*/
private function processSuccessfulRequest(Request $request, $body)
{
$response = $request->getResponse();
$headers = $request->getHeaders()->getAll();
$responseBody = $response->getBody(true);
$status = $response->getStatusCode();
$this->lastRequest['response']['body'] = $responseBody;
$this->lastRequest['response']['status'] = $status;
$this->logRequestSuccess($request->getMethod(), $request->getUrl(), $body, $headers, $status, $responseBody, $response->getInfo('total_time'));
}
示例9: testRequestHasMethod
/**
* @covers Guzzle\Http\Message\Request::getMethod
*/
public function testRequestHasMethod()
{
$this->assertEquals('GET', $this->request->getMethod());
}
示例10: getMethod
/**
* {@inheritDoc}
*/
public function getMethod()
{
return $this->request->getMethod();
}