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


PHP HTTP_Request2_Response::getStatus方法代码示例

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


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

示例1: validateResponseStatus

 public function validateResponseStatus(Am_Paysystem_Result $result)
 {
     if ($this->response->getStatus() != 200) {
         $result->setErrorMessages(array("Received invalid response from payment server: " . $this->response->getStatus()));
         return false;
     }
     return true;
 }
开发者ID:subashemphasize,项目名称:test_site,代码行数:8,代码来源:CreditCard.php

示例2: callbackWriteHeader

 /**
  * Callback function called by cURL for saving the response headers
  *
  * @param    resource    cURL handle
  * @param    string      response header (with trailing CRLF)
  * @return   integer     number of bytes saved
  * @see      HTTP_Request2_Response::parseHeaderLine()
  */
 protected function callbackWriteHeader($ch, $string)
 {
     // we may receive a second set of headers if doing e.g. digest auth
     if ($this->eventReceivedHeaders || !$this->eventSentHeaders) {
         // don't bother with 100-Continue responses (bug #15785)
         if (!$this->eventSentHeaders || $this->response->getStatus() >= 200) {
             $this->request->setLastEvent('sentHeaders', curl_getinfo($ch, CURLINFO_HEADER_OUT));
         }
         $this->eventSentHeaders = true;
         // we'll need a new response object
         if ($this->eventReceivedHeaders) {
             $this->eventReceivedHeaders = false;
             $this->response = null;
         }
     }
     if (empty($this->response)) {
         $this->response = new HTTP_Request2_Response($string, false);
     } else {
         $this->response->parseHeaderLine($string);
         if ('' == trim($string)) {
             // don't bother with 100-Continue responses (bug #15785)
             if (200 <= $this->response->getStatus()) {
                 $this->request->setLastEvent('receivedHeaders', $this->response);
             }
             $this->eventReceivedHeaders = true;
         }
     }
     return strlen($string);
 }
开发者ID:bigpussy,项目名称:statusnet,代码行数:37,代码来源:Curl.php

示例3: send

 /**
  * Processes the reuqest through HTTP pipeline with passed $filters, 
  * sends HTTP request to the wire and process the response in the HTTP pipeline.
  * 
  * @param array $filters HTTP filters which will be applied to the request before
  *                       send and then applied to the response.
  * @param IUrl  $url     Request url.
  * 
  * @throws WindowsAzure\Common\ServiceException
  * 
  * @return string The response body
  */
 public function send($filters, $url = null)
 {
     if (isset($url)) {
         $this->setUrl($url);
         $this->_request->setUrl($this->_requestUrl->getUrl());
     }
     $contentLength = Resources::EMPTY_STRING;
     if (strtoupper($this->getMethod()) != Resources::HTTP_GET && strtoupper($this->getMethod()) != Resources::HTTP_DELETE && strtoupper($this->getMethod()) != Resources::HTTP_HEAD) {
         $contentLength = 0;
         if (!is_null($this->getBody())) {
             $contentLength = strlen($this->getBody());
         }
         $this->_request->setHeader(Resources::CONTENT_LENGTH, $contentLength);
     }
     foreach ($filters as $filter) {
         $this->_request = $filter->handleRequest($this)->_request;
     }
     $this->_response = $this->_request->send();
     $start = count($filters) - 1;
     for ($index = $start; $index >= 0; --$index) {
         $this->_response = $filters[$index]->handleResponse($this, $this->_response);
     }
     self::throwIfError($this->_response->getStatus(), $this->_response->getReasonPhrase(), $this->_response->getBody(), $this->_expectedStatusCodes);
     return $this->_response->getBody();
 }
开发者ID:southworkscom,项目名称:azure-sdk-for-php,代码行数:37,代码来源:HttpClient.php

示例4: __construct

 /**
  * Constructor.
  *
  * @param string|HTTP_Request $messageOrResponse a string (UTF-8) describing
  *                                               the error, or the
  *                                               HTTP_Request2_Response that
  *                                               caused the exception.
  * @param int                 $code              the error code.
  */
 public function __construct($messageOrResponse, $code = 0)
 {
     $message = false;
     if ($messageOrResponse instanceof HTTP_Request2_Response) {
         $this->response = $messageOrResponse;
         $contentType = $this->response->getHeader('content-type');
         if ($contentType == 'application/xml' && $this->response->getBody()) {
             $prevUseInternalErrors = libxml_use_internal_errors(true);
             $doc = new DOMDocument();
             $ok = $doc->loadXML($this->response->getBody());
             libxml_use_internal_errors($prevUseInternalErrors);
             if ($ok) {
                 $xPath = new DOMXPath($doc);
                 $this->_amazonErrorCode = $xPath->evaluate('string(/Error/Code)');
                 $message = $xPath->evaluate('string(/Error/Message)');
             }
         }
         if (!$message) {
             $message = 'Bad response from server.';
         }
         if (!$code) {
             $code = $this->response->getStatus();
         }
     } else {
         $message = (string) $messageOrResponse;
     }
     parent::__construct($message, $code);
 }
开发者ID:nickaggarwal,项目名称:sample-symfony2,代码行数:37,代码来源:Exception.php

示例5: shouldRetry

 /**
  * Indicates if there should be a retry or not.
  * 
  * @param integer                 $retryCount The retry count.
  * @param \HTTP_Request2_Response $response   The HTTP response object.
  * 
  * @return boolean
  */
 public function shouldRetry($retryCount, $response)
 {
     if ($retryCount >= $this->_maximumAttempts || array_search($response->getStatus(), $this->_retryableStatusCodes) || is_null($response)) {
         return false;
     } else {
         return true;
     }
 }
开发者ID:rdohms,项目名称:azure-sdk-for-php,代码行数:16,代码来源:ExponentialRetryPolicy.php

示例6: sendRequest

 /**
  * Sends the request via HTTP_Request2
  * 
  * @return string The HTTP response body
  */
 protected function sendRequest()
 {
     $this->getHTTPRequest2();
     $this->response = $this->request->send();
     if ($this->response->getStatus() !== 200) {
         throw new OpenID_Discover_Exception('Unable to connect to OpenID Provider.');
     }
     return $this->response->getBody();
 }
开发者ID:shupp,项目名称:openid,代码行数:14,代码来源:HTML.php

示例7: callbackWriteHeader

 /**
  * Callback function called by cURL for saving the response headers
  *
  * @param    resource    cURL handle
  * @param    string      response header (with trailing CRLF)
  * @return   integer     number of bytes saved
  * @see      HTTP_Request2_Response::parseHeaderLine()
  */
 protected function callbackWriteHeader($ch, $string)
 {
     // we may receive a second set of headers if doing e.g. digest auth
     if ($this->eventReceivedHeaders || !$this->eventSentHeaders) {
         // don't bother with 100-Continue responses (bug #15785)
         if (!$this->eventSentHeaders || $this->response->getStatus() >= 200) {
             $this->request->setLastEvent('sentHeaders', curl_getinfo($ch, CURLINFO_HEADER_OUT));
         }
         $upload = curl_getinfo($ch, CURLINFO_SIZE_UPLOAD);
         // if body wasn't read by a callback, send event with total body size
         if ($upload > $this->position) {
             $this->request->setLastEvent('sentBodyPart', $upload - $this->position);
             $this->position = $upload;
         }
         if ($upload && (!$this->eventSentHeaders || $this->response->getStatus() >= 200)) {
             $this->request->setLastEvent('sentBody', $upload);
         }
         $this->eventSentHeaders = true;
         // we'll need a new response object
         if ($this->eventReceivedHeaders) {
             $this->eventReceivedHeaders = false;
             $this->response = null;
         }
     }
     if (empty($this->response)) {
         $this->response = new HTTP_Request2_Response($string, false);
     } else {
         $this->response->parseHeaderLine($string);
         if ('' == trim($string)) {
             // don't bother with 100-Continue responses (bug #15785)
             if (200 <= $this->response->getStatus()) {
                 $this->request->setLastEvent('receivedHeaders', $this->response);
             }
             if ($this->request->getConfig('follow_redirects') && $this->response->isRedirect()) {
                 $redirectUrl = new Net_URL2($this->response->getHeader('location'));
                 // for versions lower than 5.2.10, check the redirection URL protocol
                 if (!defined('CURLOPT_REDIR_PROTOCOLS') && $redirectUrl->isAbsolute() && !in_array($redirectUrl->getScheme(), array('http', 'https'))) {
                     return -1;
                 }
                 if ($jar = $this->request->getCookieJar()) {
                     $jar->addCookiesFromResponse($this->response, $this->request->getUrl());
                     if (!$redirectUrl->isAbsolute()) {
                         $redirectUrl = $this->request->getUrl()->resolve($redirectUrl);
                     }
                     if ($cookies = $jar->getMatching($redirectUrl, true)) {
                         curl_setopt($ch, CURLOPT_COOKIE, $cookies);
                     }
                 }
             }
             $this->eventReceivedHeaders = true;
         }
     }
     return strlen($string);
 }
开发者ID:venamax,项目名称:trixandtrax-cl,代码行数:62,代码来源:Curl.php

示例8: testParseStatusLine

 /**
  *
  * @expectedException HTTP_Request2_MessageException
  */
 public function testParseStatusLine()
 {
     $response = new HTTP_Request2_Response('HTTP/1.1 200 OK');
     $this->assertEquals('1.1', $response->getVersion());
     $this->assertEquals(200, $response->getStatus());
     $this->assertEquals('OK', $response->getReasonPhrase());
     $response2 = new HTTP_Request2_Response('HTTP/1.2 222 Nishtyak!');
     $this->assertEquals('1.2', $response2->getVersion());
     $this->assertEquals(222, $response2->getStatus());
     $this->assertEquals('Nishtyak!', $response2->getReasonPhrase());
     $response3 = new HTTP_Request2_Response('Invalid status line');
 }
开发者ID:Geeklog-Core,项目名称:geeklog,代码行数:16,代码来源:ResponseTest.php

示例9: testParseStatusLine

 public function testParseStatusLine()
 {
     $response = new HTTP_Request2_Response('HTTP/1.1 200 OK');
     $this->assertEquals('1.1', $response->getVersion());
     $this->assertEquals(200, $response->getStatus());
     $this->assertEquals('OK', $response->getReasonPhrase());
     $response2 = new HTTP_Request2_Response('HTTP/1.2 222 Nishtyak!');
     $this->assertEquals('1.2', $response2->getVersion());
     $this->assertEquals(222, $response2->getStatus());
     $this->assertEquals('Nishtyak!', $response2->getReasonPhrase());
     try {
         $response3 = new HTTP_Request2_Response('Invalid status line');
     } catch (HTTP_Request2_Exception $e) {
         return;
     }
     $this->fail('Expected HTTP_Request2_Exception was not thrown');
 }
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:17,代码来源:ResponseTest.php

示例10: __construct

 /**
  * Constructor.
  *
  * @param string                                         $content Http response
  *                                                                as string
  * @param WindowsAzure\Common\Internal\Http\BatchRequest $request Source batch
  *                                                                request object
  */
 public function __construct($content, $request = null)
 {
     $params['include_bodies'] = true;
     $params['input'] = $content;
     $mimeDecoder = new \Mail_mimeDecode($content);
     $structure = $mimeDecoder->decode($params);
     $parts = $structure->parts;
     $this->_contexts = array();
     $requestContexts = null;
     if ($request != null) {
         Validate::isA($request, 'WindowsAzure\\Common\\Internal\\Http\\BatchRequest', 'request');
         $requestContexts = $request->getContexts();
     }
     $i = 0;
     foreach ($parts as $part) {
         if (!empty($part->body)) {
             $headerEndPos = strpos($part->body, "\r\n\r\n");
             $header = substr($part->body, 0, $headerEndPos);
             $body = substr($part->body, $headerEndPos + 4);
             $headerStrings = explode("\r\n", $header);
             $response = new \HTTP_Request2_Response(array_shift($headerStrings));
             foreach ($headerStrings as $headerString) {
                 $response->parseHeaderLine($headerString);
             }
             $response->appendBody($body);
             $this->_contexts[] = $response;
             if (is_array($requestContexts)) {
                 $expectedCodes = $requestContexts[$i]->getStatusCodes();
                 $statusCode = $response->getStatus();
                 if (!in_array($statusCode, $expectedCodes)) {
                     $reason = $response->getReasonPhrase();
                     throw new ServiceException($statusCode, $reason, $body);
                 }
             }
             ++$i;
         }
     }
 }
开发者ID:southworkscom,项目名称:azure-sdk-for-php,代码行数:46,代码来源:BatchResponse.php

示例11: parseResponse

 /**
  * Parse the response!
  *
  * @param HttpResponse $response
  * @param bool         $assocParse
  *
  * @return stdClass
  *
  * @throws \RuntimeException         When the API returns an error.
  * @throws \UnexpectedValueExpection When the body is not proper JSON.
  */
 protected function parseResponse(HttpResponse $response, $assocParse = false)
 {
     $json = $response->getBody();
     $body = @json_decode($json, $assocParse);
     if (empty($body)) {
         throw new \UnexpectedValueException('body is not proper JSON, status=' . $response->getStatus() . ', body=' . $json);
     }
     if ($response->getStatus() == 200) {
         return $body;
     }
     $message = '';
     $errors = $body->errors;
     foreach ($errors as $error) {
         if (!empty($message)) {
             $message .= ', ';
         }
         if (is_string($error)) {
             $message .= $error;
         }
     }
     throw new \RuntimeException($message);
 }
开发者ID:till,项目名称:services_librato,代码行数:33,代码来源:Librato.php

示例12: parseResponse

 /**
  * Parse the response
  *
  * This method is used to parse the response that is returned from
  * the request that was made in $this->sendRequest().
  *
  * @throws Services_Capsule_RuntimeException
  *
  * @param  HTTP_Request2_Response $response  The response from the webservice.
  * @return mixed               stdClass|bool A stdClass object of the 
  *                                           json-decode'ed body or true if
  *                                           the code is 201 (created)
  */
 protected function parseResponse(HTTP_Request2_Response $response)
 {
     $body = $response->getBody();
     $return = json_decode($body);
     if (!$return instanceof stdClass) {
         if ($response->getStatus() == 201 || $response->getStatus() == 200) {
             return true;
         }
         throw new Services_Capsule_RuntimeException('Invalid response with no valid json body');
     }
     return $return;
 }
开发者ID:beckskis,项目名称:Services_Capsule,代码行数:25,代码来源:Common.php

示例13: validateResponseStatus

 protected function validateResponseStatus(HTTP_Request2_Response $response, Am_Paysystem_Result $result)
 {
     if ($response->getStatus() != 200) {
         $result->setFailed(array("Received invalid response from payment server: " . $this->response->getStatus()));
     }
 }
开发者ID:alexanderTsig,项目名称:arabic,代码行数:6,代码来源:paymill-dd.php

示例14: _return

 /**
  * evaluate response object
  *
  * @param \HTTP_Request2_Response $resp
  *
  * @throws BadRequestError
  * @throws UnauthorizedError
  * @throws ForbiddenError
  * @throws ConflictDuplicateError
  * @throws GoneError
  * @throws InternalServerError
  * @throws NotImplementedError
  * @throws ThrottledError
  * @throws CCException
  *
  * @return string json encoded servers response
  */
 private function _return($resp)
 {
     #
     # And handle the possible responses according to their HTTP STATUS
     # CODES.
     #
     # 200 OK, 201 CREATED and 204 DELETED result in returning the actual
     # response.
     #
     # All non success STATUS CODES raise an exception containing
     # the API error message.
     #
     if (in_array($resp->getStatus(), array(200, 201, 204)) !== false) {
         return $resp->getBody();
     } else {
         if ($resp->getStatus() == 400) {
             throw new BadRequestError($resp->getBody(), $resp->getStatus());
         } else {
             if ($resp->getStatus() == 401) {
                 throw new UnauthorizedError($resp->getBody(), $resp->getStatus());
             } else {
                 if ($resp->getStatus() == 403) {
                     throw new ForbiddenError($resp->getBody(), $resp->getStatus());
                 } else {
                     if ($resp->getStatus() == 409) {
                         throw new ConflictDuplicateError($resp->getBody(), $resp->getStatus());
                     } else {
                         if ($resp->getStatus() == 410) {
                             throw new GoneError($resp->getBody(), $resp->getStatus());
                         } else {
                             if ($resp->getStatus() == 500) {
                                 throw new InternalServerError($resp->getBody(), $resp->getStatus());
                             } else {
                                 if ($resp->getStatus() == 501) {
                                     throw new NotImplementedError($resp->getBody(), $resp->getStatus());
                                 } else {
                                     if ($resp->getStatus() == 503) {
                                         throw new ThrottledError($resp->getBody(), $resp->getStatus());
                                     } else {
                                         throw new CCException($resp->getBody(), $resp->getStatus());
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:cloudcontrol,项目名称:phpcclib,代码行数:67,代码来源:API.php

示例15: processResponse

 /**
  * Saves the response body to a specified directory
  *
  * @param  HTTP_Request2_Response $response
  * @return void
  * @throws BuildException
  */
 protected function processResponse(HTTP_Request2_Response $response)
 {
     if ($response->getStatus() != 200) {
         throw new BuildException("Request unsuccessful. Response from server: " . $response->getStatus() . " " . $response->getReasonPhrase());
     }
     $content = $response->getBody();
     $disposition = $response->getHeader('content-disposition');
     if ($this->filename) {
         $filename = $this->filename;
     } elseif ($disposition && 0 == strpos($disposition, 'attachment') && preg_match('/filename="([^"]+)"/', $disposition, $m)) {
         $filename = basename($m[1]);
     } else {
         $filename = basename(parse_url($this->url, PHP_URL_PATH));
     }
     if (!is_writable($this->dir)) {
         throw new BuildException("Cannot write to directory: " . $this->dir);
     }
     $filename = $this->dir . "/" . $filename;
     file_put_contents($filename, $content);
     $this->log("Contents from " . $this->url . " saved to {$filename}");
 }
开发者ID:Ingewikkeld,项目名称:phing,代码行数:28,代码来源:HttpGetTask.php


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