当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::getMethod方法代码示例

本文整理汇总了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;
 }
开发者ID:rezzza,项目名称:tk1-contexts,代码行数:10,代码来源:HttpResponseTimeBenchmark.php

示例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);
 }
开发者ID:sgulseth,项目名称:imboclient-php,代码行数:18,代码来源:Authenticate.php

示例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);
 }
开发者ID:chartblocks,项目名称:php-rest-sdk,代码行数:15,代码来源:Signature.php

示例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);
 }
开发者ID:victormacko,项目名称:trucker,代码行数:20,代码来源:RestRequest.php

示例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();
 }
开发者ID:caxy,项目名称:acquia-sdk-php,代码行数:19,代码来源:AcquiaSearchAuthPlugin.php

示例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);
     }
 }
开发者ID:puwenhan,项目名称:twitter-sdk,代码行数:19,代码来源:Twitter.php

示例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);
                 }
             }
         }
     }
 }
开发者ID:rllmwm,项目名称:forbiddencat,代码行数:40,代码来源:ApiFeatureContext.php

示例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'));
 }
开发者ID:security-geeks,项目名称:squert,代码行数:14,代码来源:GuzzleConnection.php

示例9: testRequestHasMethod

 /**
  * @covers Guzzle\Http\Message\Request::getMethod
  */
 public function testRequestHasMethod()
 {
     $this->assertEquals('GET', $this->request->getMethod());
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:7,代码来源:RequestTest.php

示例10: getMethod

 /**
  * {@inheritDoc}
  */
 public function getMethod()
 {
     return $this->request->getMethod();
 }
开发者ID:acquia,项目名称:hmac-request,代码行数:7,代码来源:Guzzle3.php


注:本文中的Guzzle\Http\Message\Request::getMethod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。