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


PHP RequestInterface::getMethod方法代码示例

本文整理汇总了PHP中GuzzleHttp\Message\RequestInterface::getMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestInterface::getMethod方法的具体用法?PHP RequestInterface::getMethod怎么用?PHP RequestInterface::getMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GuzzleHttp\Message\RequestInterface的用法示例。


在下文中一共展示了RequestInterface::getMethod方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createRingRequest

 /**
  * Creates a Ring request from a request object.
  *
  * This function does not hook up the "then" and "progress" events that
  * would be required for actually sending a Guzzle request through a
  * RingPHP handler.
  *
  * @param RequestInterface $request Request to convert.
  *
  * @return array Converted Guzzle Ring request.
  */
 public static function createRingRequest(RequestInterface $request)
 {
     $options = $request->getConfig()->toArray();
     $url = $request->getUrl();
     // No need to calculate the query string twice (in URL and query).
     $qs = ($pos = strpos($url, '?')) ? substr($url, $pos + 1) : null;
     return ['scheme' => $request->getScheme(), 'http_method' => $request->getMethod(), 'url' => $url, 'uri' => $request->getPath(), 'headers' => $request->getHeaders(), 'body' => $request->getBody(), 'version' => $request->getProtocolVersion(), 'client' => $options, 'query_string' => $qs, 'future' => isset($options['future']) ? $options['future'] : false];
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:19,代码来源:RingBridge.php

示例2: execute

 /**
  * Executes a GuzzleHttp\Message\Request and (if applicable) automatically retries
  * when errors occur.
  *
  * @param Google_Client $client
  * @param GuzzleHttp\Message\Request $req
  * @return array decoded result
  * @throws Google_Service_Exception on server side error (ie: not authenticated,
  *  invalid or malformed post body, invalid url)
  */
 public static function execute(ClientInterface $client, RequestInterface $request, $config = array(), $retryMap = null)
 {
     $runner = new Google_Task_Runner($config, sprintf('%s %s', $request->getMethod(), $request->getUrl()), array(get_class(), 'doExecute'), array($client, $request));
     if (!is_null($retryMap)) {
         $runner->setRetryMap($retryMap);
     }
     return $runner->run();
 }
开发者ID:rahul9878,项目名称:google-api-php-client,代码行数:18,代码来源:REST.php

示例3: getRequestAndQuery

 /**
  * @param RequestInterface $request
  * @return array ['query' => ..., 'request' => ...]
  */
 protected function getRequestAndQuery(RequestInterface $request)
 {
     $query = [];
     foreach ($request->getQuery() as $param => $val) {
         $query[$param] = $val;
     }
     $requestInfo = ['url' => $request->getUrl(), 'path' => $request->getPath(), 'queryString' => (string) $request->getQuery(), 'method' => $request->getMethod(), 'hostname' => $request->getHost(), 'port' => $request->getPort(), 'resource' => $request->getResource()];
     return ['query' => $query, 'request' => $requestInfo];
 }
开发者ID:keboola,项目名称:generic-extractor,代码行数:13,代码来源:AbstractSignature.php

示例4: buildMessage

 /**
  * @param RequestInterface $request
  * @param ResponseInterface $response
  * @return string
  */
 protected function buildMessage($request, $response)
 {
     $resource = $this->getResponseBody();
     if (is_null($resource)) {
         $resource = '';
     }
     $message = sprintf('[url] %s [http method] %s [status code] %s [reason phrase] %s: %s', $request->getUrl(), $request->getMethod(), $response->getStatusCode(), $response->getReasonPhrase(), $resource);
     return $message;
 }
开发者ID:finix-payments,项目名称:processing-php-client,代码行数:14,代码来源:HalException.php

示例5: checkRequest

 /**
  * @param RequestInterface $actual
  * @param RequestInterface $expected
  * @throws FailedRequestExpectationException
  */
 public static function checkRequest(RequestInterface $actual, RequestInterface $expected)
 {
     self::checkIsEqual($actual->getHost(), $expected->getHost(), 'host');
     self::checkIsEqual($actual->getPath(), $expected->getPath(), 'url path');
     self::checkIsEqual($actual->getMethod(), $expected->getMethod(), 'http method');
     self::checkRequestQuery($actual, $expected);
     self::checkContentType($actual, $expected);
     self::checkRequestBody($actual, $expected);
 }
开发者ID:lezhnev74,项目名称:GuzzleHttpMock,代码行数:14,代码来源:RequestChecker.php

示例6: createCanonicalizedString

 private function createCanonicalizedString(RequestInterface $request, $expires = null)
 {
     $buffer = $request->getMethod() . "\n";
     // Add the interesting headers
     foreach ($this->signableHeaders as $header) {
         $buffer .= $request->getHeader($header) . "\n";
     }
     $date = $expires ?: $request->getHeader('date');
     $buffer .= "{$date}\n" . $this->createCanonicalizedAmzHeaders($request) . $this->createCanonicalizedResource($request);
     return $buffer;
 }
开发者ID:briareos,项目名称:aws-sdk-php,代码行数:11,代码来源:S3Signature.php

示例7: shouldValidate

 private function shouldValidate(RequestInterface $request, ResponseInterface $response)
 {
     if ($request->getMethod() != 'GET' || $request->getConfig()->get('cache.disable')) {
         return false;
     }
     $validate = Utils::getDirective($request, 'Pragma') === 'no-cache' || Utils::getDirective($response, 'Pragma') === 'no-cache' || Utils::getDirective($request, 'must-revalidate') || Utils::getDirective($response, 'must-revalidate') || Utils::getDirective($request, 'no-cache') || Utils::getDirective($response, 'no-cache') || Utils::getDirective($response, 'max-age') === '0' || Utils::getDirective($response, 's-maxage') === '0';
     // Use the strong ETag validator if available and the response contains
     // no Cache-Control directive
     if (!$validate && !$response->hasHeader('Cache-Control') && $response->hasHeader('ETag')) {
         $validate = true;
     }
     return $validate;
 }
开发者ID:thomaschaaf,项目名称:cache-subscriber,代码行数:13,代码来源:ValidationSubscriber.php

示例8: applyMethod

 private function applyMethod(RequestInterface $request, array &$options)
 {
     $method = $request->getMethod();
     if ($method == 'HEAD') {
         $options[CURLOPT_NOBODY] = true;
         unset($options[CURLOPT_WRITEFUNCTION], $options[CURLOPT_READFUNCTION]);
     } else {
         $options[CURLOPT_CUSTOMREQUEST] = $method;
         if (!$request->getBody()) {
             unset($options[CURLOPT_READFUNCTION]);
         } else {
             $this->applyBody($request, $options);
         }
     }
 }
开发者ID:ChenOhayon,项目名称:sitepoint_codes,代码行数:15,代码来源:CurlFactory.php

示例9: signRequest

 public function signRequest(RequestInterface $request, CredentialsInterface $credentials)
 {
     /** @var PostBodyInterface $body */
     $body = $request->getBody();
     $body->setField('Timestamp', gmdate('c'));
     $body->setField('SignatureVersion', '2');
     $body->setField('SignatureMethod', 'HmacSHA256');
     $body->setField('AWSAccessKeyId', $credentials->getAccessKeyId());
     if ($token = $credentials->getSecurityToken()) {
         $body->setField('SecurityToken', $token);
     }
     // build string to sign
     $sign = $request->getMethod() . "\n" . $request->getHost() . "\n" . '/' . "\n" . $this->getCanonicalizedParameterString($body);
     $request->getConfig()->set('aws.signature', $sign);
     $body->setField('Signature', base64_encode(hash_hmac('sha256', $sign, $credentials->getSecretKey(), true)));
 }
开发者ID:briareos,项目名称:aws-sdk-php,代码行数:16,代码来源:SignatureV2.php

示例10: send

 public function send(RequestInterface $request)
 {
     $this->logger->info(sprintf('%s "%s"', $request->getMethod(), $request->getUrl()));
     $this->logger->debug(sprintf("Request:\n%s", (string) $request));
     try {
         $response = $this->client->send($request);
     } catch (TransferException $e) {
         $message = sprintf('Something went wrong when calling vault (%s).', $e->getMessage());
         $this->logger->error($message);
         throw new ServerException($message);
     }
     $this->logger->debug(sprintf("Response:\n%s", $response));
     if (400 <= $response->getStatusCode()) {
         $message = sprintf('Something went wrong when calling vault (%s - %s).', $response->getStatusCode(), $response->getReasonPhrase());
         $this->logger->error($message);
         $message .= "\n{$response}";
         if (500 <= $response->getStatusCode()) {
             throw new ServerException($message, $response->getStatusCode(), $response);
         }
         throw new ClientException($message, $response->getStatusCode(), $response);
     }
     return $response;
 }
开发者ID:jippi,项目名称:vault-php-sdk,代码行数:23,代码来源:Client.php

示例11: getCacheKey

 /**
  * Hash a request URL into a string that returns cache metadata.
  *
  * @param RequestInterface $request The Request to generate the cache key
  *                                  for.
  * @param array            $vary    (optional) An array of headers to vary
  *                                  the cache key by.
  *
  * @return string
  */
 private function getCacheKey(RequestInterface $request, array $vary = [])
 {
     $key = $request->getMethod() . ' ' . $request->getUrl();
     // If Vary headers have been passed in, fetch each header and add it to
     // the cache key.
     foreach ($vary as $header) {
         $key .= " {$header}: " . $request->getHeader($header);
     }
     return $this->keyPrefix . md5($key);
 }
开发者ID:thomaschaaf,项目名称:cache-subscriber,代码行数:20,代码来源:CacheStorage.php

示例12: extractBodyArgument

 /**
  * @param RequestInterface $request
  */
 protected function extractBodyArgument(RequestInterface $request)
 {
     if ($request->getBody() && ($contents = (string) $request->getBody())) {
         $this->addOption('d', escapeshellarg($contents));
     }
     //if get request has data Add G otherwise curl will make a post request
     if (!empty($this->options['d']) && 'GET' === $request->getMethod()) {
         $this->addOption('G');
     }
 }
开发者ID:mdrost,项目名称:cuzzle,代码行数:13,代码来源:CurlFormatter.php

示例13: format

 /**
  * Returns a formatted message
  *
  * @param RequestInterface  $request    Request that was sent
  * @param ResponseInterface $response   Response that was received
  * @param \Exception        $error      Exception that was received
  * @param array             $customData Associative array of custom template data
  *
  * @return string
  */
 public function format(RequestInterface $request, ResponseInterface $response = null, \Exception $error = null, array $customData = array())
 {
     $cache = $customData;
     $that = $this;
     return preg_replace_callback('/{\\s*([A-Za-z_\\-\\.0-9]+)\\s*}/', function (array $matches) use($request, $response, $error, &$cache, $that) {
         if (isset($cache[$matches[1]])) {
             return $cache[$matches[1]];
         }
         $result = '';
         switch ($matches[1]) {
             case 'request':
                 $result = $request;
                 break;
             case 'response':
                 $result = $response;
                 break;
             case 'req_headers':
                 $result = trim($request->getMethod() . ' ' . $request->getResource()) . ' HTTP/' . $request->getProtocolVersion() . "\r\n" . $that->headers($request);
                 break;
             case 'res_headers':
                 $result = $response ? sprintf('HTTP/%s %d %s', $response->getProtocolVersion(), $response->getStatusCode(), $response->getReasonPhrase()) . "\r\n" . $that->headers($response) : 'NULL';
                 break;
             case 'req_body':
                 $result = $request->getBody();
                 break;
             case 'res_body':
                 $result = $response ? $response->getBody() : 'NULL';
                 break;
             case 'ts':
                 $result = gmdate('c');
                 break;
             case 'method':
                 $result = $request->getMethod();
                 break;
             case 'url':
                 $result = $request->getUrl();
                 break;
             case 'resource':
                 $result = $request->getResource();
                 break;
             case 'req_version':
                 $result = $request->getProtocolVersion();
                 break;
             case 'res_version':
                 $result = $response ? $response->getProtocolVersion() : 'NULL';
                 break;
             case 'host':
                 $result = $request->getHost();
                 break;
             case 'hostname':
                 $result = gethostname();
                 break;
             case 'code':
                 $result = $response ? $response->getStatusCode() : 'NULL';
                 break;
             case 'phrase':
                 $result = $response ? $response->getReasonPhrase() : 'NULL';
                 break;
             case 'error':
                 $result = $error ? $error->getMessage() : 'NULL';
                 break;
             default:
                 // handle prefixed dynamic headers
                 if (strpos($matches[1], 'req_header_') === 0) {
                     $result = $request->getHeader(substr($matches[1], 11));
                 } elseif (strpos($matches[1], 'res_header_') === 0) {
                     $result = $response ? $response->getHeader(substr($matches[1], 11)) : 'NULL';
                 }
         }
         $cache[$matches[1]] = $result;
         return $result;
     }, $this->template);
 }
开发者ID:bobozhangshao,项目名称:HeartCare,代码行数:83,代码来源:Formatter.php

示例14: getDefaultOptions

 private function getDefaultOptions(RequestInterface $request)
 {
     $headers = '';
     foreach ($request->getHeaders() as $name => $values) {
         $headers .= $name . ': ' . implode(', ', $values) . "\r\n";
     }
     return ['http' => ['method' => $request->getMethod(), 'header' => trim($headers), 'protocol_version' => $request->getProtocolVersion(), 'ignore_errors' => true, 'follow_location' => 0, 'content' => (string) $request->getBody()]];
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:8,代码来源:StreamAdapter.php

示例15: error

 /**
  * Handle an error. We handle errors by throwing an exception.
  *
  * @param string $error An error code representing the error
  *                      (use_underscore_separators).
  * @param string|null $message The error message.
  * @param \GuzzleHttp\Message\RequestInterface|null $request Optional. The
  *                                                  Guzzle request object.
  * @param \GuzzleHttp\Message\ResponseInterface|null $response Optional. The
  *                                                   Guzzle response object.
  *
  * @return void
  * @throws \Box\View\BoxViewException
  */
 protected static function error($error, $message = null, $request = null, $response = null)
 {
     if (!empty($request)) {
         $message .= "\n";
         $message .= 'Method: ' . $request->getMethod() . "\n";
         $message .= 'URL: ' . $request->getUrl() . "\n";
         $message .= 'Query: ' . json_encode($request->getQuery()->toArray()) . "\n";
         $message .= 'Headers: ' . json_encode($request->getHeaders()) . "\n";
         $message .= 'Request Body: ' . $request->getBody() . "\n";
     }
     if (!empty($response)) {
         $message .= "\n";
         $message .= 'Response Body: ' . $response->getBody() . "\n";
     }
     $exception = new BoxViewException($message);
     $exception->errorCode = $error;
     throw $exception;
 }
开发者ID:anx-hnezbeda,项目名称:php-box-view,代码行数:32,代码来源:Request.php


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