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


PHP ResponseInterface::getStatusCode方法代码示例

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


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

示例1: userMovedFile

 /**
  * @Given /^User "([^"]*)" moved file "([^"]*)" to "([^"]*)"$/
  * @param string $user
  * @param string $fileSource
  * @param string $fileDestination
  */
 public function userMovedFile($user, $fileSource, $fileDestination)
 {
     $fullUrl = substr($this->baseUrl, 0, -4) . $this->davPath;
     $headers['Destination'] = $fullUrl . $fileDestination;
     $this->response = $this->makeDavRequest($user, "MOVE", $fileSource, $headers);
     PHPUnit_Framework_Assert::assertEquals(201, $this->response->getStatusCode());
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:13,代码来源:WebDav.php

示例2: isNotJsonError

 private function isNotJsonError(HttpResponseInterface $httpResponse)
 {
     if ($httpResponse->getStatusCode() == ResponseInterface::HTTP_CODE_NOT_FOUND || $httpResponse->getStatusCode() == ResponseInterface::HTTP_CODE_INTERNAL_SERVER_ERROR || $httpResponse->getStatusCode() == ResponseInterface::HTTP_CODE_METHOD_NOT_ALLOWED) {
         return true;
     }
     return false;
 }
开发者ID:boylen,项目名称:virgil-php-keys,代码行数:7,代码来源:Connection.php

示例3: _getResult

 /**
  * @param ResponseInterface $response
  *
  * @return ApiResult
  */
 protected function _getResult($response)
 {
     if (!$response instanceof ResponseInterface) {
         throw new \InvalidArgumentException("{$response} should be an instance of ResponseInterface");
     }
     $result = new ApiResult();
     $result->setStatusCode($response->getStatusCode());
     $callId = $response->getHeader('X-Call-Id');
     if (!empty($callId)) {
         $result->setCallId($callId);
     }
     $decoded = json_decode((string) $response->getBody());
     if (isset($decoded->meta) && isset($decoded->data) && isset($decoded->meta->code) && $decoded->meta->code == $response->getStatusCode()) {
         $meta = $decoded->meta;
         $data = $decoded->data;
         if (isset($meta->message)) {
             $result->setStatusMessage($meta->message);
         }
         $result->setContent(json_encode($data));
     } else {
         $result->setContent((string) $response->getBody());
     }
     $result->setHeaders($response->getHeaders());
     return $result;
 }
开发者ID:fortifi,项目名称:api,代码行数:30,代码来源:Guzzle5Connection.php

示例4: status

 /**
  * Asserts the HTTP response status code.
  *
  * @param string $status Expected status code
  *
  * @throws \RuntimeException If status code does not match
  *
  * @return self
  */
 public function status($status)
 {
     $httpStatus = (string) $this->response->getStatusCode();
     if ($httpStatus !== $status) {
         throw new \RuntimeException("Unexpected response status code: {$httpStatus}");
     }
     return $this;
 }
开发者ID:sam-akopyan,项目名称:hamradio,代码行数:17,代码来源:ResponseValidator.php

示例5: setResponse

 /**
  * Set Http response in case of successful request
  * 
  * @param GuzzleHttp\Message\ResponseInterface $response
  * @return CurrencyExchange\HttpClient
  * @throws CurrencyExchange\Exception\ResponseException
  */
 public function setResponse(ResponseInterface $response)
 {
     if ($response->getStatusCode() != 200) {
         throw new ResponseException('Unsuccessful HTTP request: ' . $response->getStatusCode() . ' on ' . $this->getUri());
     }
     $this->_response = $response;
     return $this;
 }
开发者ID:teknoman,项目名称:currency-exchange,代码行数:15,代码来源:Client.php

示例6: __construct

 public function __construct(ResponseInterface $response)
 {
     try {
         $this->details = $response->json();
         $message = isset($this->details['error']['message']) ? $this->details['error']['message'] : $response->getReasonPhrase();
     } catch (ParseException $e) {
         $message = $response->getReasonPhrase();
     }
     parent::__construct(sprintf('The request failed and returned an invalid status code ("%d") : %s', $response->getStatusCode(), $message), $response->getStatusCode());
 }
开发者ID:krichprollsch,项目名称:Office365Adapter,代码行数:10,代码来源:ApiErrorException.php

示例7: theCaldavHttpStatusCodeShouldBe

 /**
  * @Then The CalDAV HTTP status code should be :code
  */
 public function theCaldavHttpStatusCodeShouldBe($code)
 {
     if ((int) $code !== $this->response->getStatusCode()) {
         throw new \Exception(sprintf('Expected %s got %s', (int) $code, $this->response->getStatusCode()));
     }
     $body = $this->response->getBody()->getContents();
     if ($body && substr($body, 0, 1) === '<') {
         $reader = new Sabre\Xml\Reader();
         $reader->xml($body);
         $this->responseXml = $reader->parse();
     }
 }
开发者ID:gvde,项目名称:core,代码行数:15,代码来源:CalDavContext.php

示例8: readNext

 /**
  * {@inheritdoc}
  */
 protected function readNext()
 {
     if (!$this->iterator->valid()) {
         return;
     }
     $message = $this->iterator->current();
     $code = $this->response->getStatusCode();
     $content = sprintf("HTTP/1.1 300\r\n %s", $message);
     $element = $this->parser->parseResponse($content);
     $current = $this->factory->createResponse($code, $element['headers'], $element['body']);
     return $current;
 }
开发者ID:php-riak,项目名称:riak-client,代码行数:15,代码来源:MultipartResponseIterator.php

示例9: handleError

 /**
  * @throws HttpException
  */
 protected function handleError()
 {
     $body = (string) $this->response->getBody();
     $code = (int) $this->response->getStatusCode();
     $content = json_decode($body);
     throw new HttpException(isset($content->message) ? $content->message : 'Request not processed.', $code);
 }
开发者ID:mix376,项目名称:DigitalOceanV2,代码行数:10,代码来源:GuzzleHttpAdapter.php

示例10: decodeHttpResponse

 /**
  * Decode an HTTP Response.
  * @static
  * @throws Google_Service_Exception
  * @param GuzzleHttp\Message\RequestInterface $response The http response to be decoded.
  * @param GuzzleHttp\Message\ResponseInterface $response
  * @return mixed|null
  */
 public static function decodeHttpResponse(ResponseInterface $response, RequestInterface $request = null)
 {
     $body = (string) $response->getBody();
     $code = $response->getStatusCode();
     $result = null;
     // return raw response when "alt" is "media"
     $isJson = !($request && 'media' == $request->getQuery()->get('alt'));
     // set the result to the body if it's not set to anything else
     if ($isJson) {
         try {
             $result = $response->json();
         } catch (ParseException $e) {
             $result = $body;
         }
     } else {
         $result = $body;
     }
     // retry strategy
     if (intVal($code) >= 300) {
         $errors = null;
         // Specific check for APIs which don't return error details, such as Blogger.
         if (isset($result['error']) && isset($result['error']['errors'])) {
             $errors = $result['error']['errors'];
         }
         throw new Google_Service_Exception($body, $code, null, $errors);
     }
     return $result;
 }
开发者ID:OlivierBarbier,项目名称:google-api-php-client,代码行数:36,代码来源:REST.php

示例11: updatingLastShare

 /**
  * @When /^Updating last share with$/
  * @param \Behat\Gherkin\Node\TableNode|null $body
  */
 public function updatingLastShare($body)
 {
     $share_id = $this->lastShareData->data[0]->id;
     $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/files_sharing/api/v{$this->sharingApiVersion}/shares/{$share_id}";
     $client = new Client();
     $options = [];
     if ($this->currentUser === 'admin') {
         $options['auth'] = $this->adminUser;
     } else {
         $options['auth'] = [$this->currentUser, $this->regularUser];
     }
     if ($body instanceof \Behat\Gherkin\Node\TableNode) {
         $fd = $body->getRowsHash();
         if (array_key_exists('expireDate', $fd)) {
             $dateModification = $fd['expireDate'];
             $fd['expireDate'] = date('Y-m-d', strtotime($dateModification));
         }
         $options['body'] = $fd;
     }
     try {
         $this->response = $client->send($client->createRequest("PUT", $fullUrl, $options));
     } catch (\GuzzleHttp\Exception\ClientException $ex) {
         $this->response = $ex->getResponse();
     }
     PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode());
 }
开发者ID:reverserob,项目名称:core,代码行数:30,代码来源:FeatureContext.php

示例12: modifyRedirectRequest

 private function modifyRedirectRequest(RequestInterface $request, ResponseInterface $response)
 {
     $config = $request->getConfig();
     // Use a GET request if this is an entity enclosing request and we are
     // not forcing RFC compliance, but rather emulating what all browsers
     // would do.
     $statusCode = $response->getStatusCode();
     if ($statusCode == 303 || $statusCode <= 302 && $request->getBody() && !$config->getPath('redirect/strict')) {
         $request->setMethod('GET');
         $request->setBody(null);
     }
     $previousUrl = $request->getUrl();
     $this->setRedirectUrl($request, $response);
     $this->rewindEntityBody($request);
     // Add the Referer header if it is told to do so and only
     // add the header if we are not redirecting from https to http.
     if ($config->getPath('redirect/referer') && ($request->getScheme() == 'https' || $request->getScheme() == $config['redirect_scheme'])) {
         $url = Url::fromString($previousUrl);
         $url->setUsername(null);
         $url->setPassword(null);
         $request->setHeader('Referer', (string) $url);
     } else {
         $request->removeHeader('Referer');
     }
 }
开发者ID:bangordailynews,项目名称:bdnindex,代码行数:25,代码来源:Redirect.php

示例13: theResponseCodeShouldBe

 /**
  * Checks that response has specific status code.
  *
  * @param string $code status code
  *
  * @Then /^(?:the )?response code should be (\d+)$/
  */
 public function theResponseCodeShouldBe($code)
 {
     $expected = intval($code);
     var_dump($this->response->getStatusCode());
     $actual = intval($this->response->getStatusCode());
     Assertions::assertSame($expected, $actual);
 }
开发者ID:cam5,项目名称:WebApiExtension,代码行数:14,代码来源:WebApiContext.php

示例14: parseHeaders

 private function parseHeaders(ResponseInterface $response, array &$data)
 {
     $data['message'] = $response->getStatusCode() . ' ' . $response->getReasonPhrase();
     if ($requestId = $response->getHeader('x-amz-request-id')) {
         $data['request_id'] = $requestId;
         $data['message'] .= " (Request-ID: {$requestId})";
     }
 }
开发者ID:briareos,项目名称:aws-sdk-php,代码行数:8,代码来源:XmlErrorParser.php

示例15: __construct

 /**
  * Gets the relevant data from the Guzzle clients.
  *
  * @param RequestInterface $request
  * @param ResponseInterface $response
  */
 public function __construct(RequestInterface $request, ResponseInterface $response)
 {
     if ($response instanceof FutureResponse) {
         $this->httpStatusCode = null;
     } else {
         $this->httpStatusCode = $response->getStatusCode();
     }
     $this->requestUrl = $request->getUrl();
 }
开发者ID:HeidiWang123,项目名称:our-world-in-data-grapher,代码行数:15,代码来源:AnalyticsResponse.php


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