• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Message\RequestInterface类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Guzzle\Http\Message\RequestInterface的典型用法代码示例。如果您正苦于以下问题:PHP RequestInterface类的具体用法?PHP RequestInterface怎么用?PHP RequestInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: onOpen

 public function onOpen(ConnectionInterface $from, RequestInterface $request = null)
 {
     echo "New HTTP connection!\n";
     //Variables in URLs are not supported in Ratchet for now
     //See https://github.com/cboden/Ratchet/pull/143
     $requestPath = $request->getPath();
     $pathParts = explode('/', preg_replace('#^/peerjs/#', '', $requestPath));
     //Remove /peerjs
     $action = array_pop($pathParts);
     $peerToken = array_pop($pathParts);
     $peerId = array_pop($pathParts);
     $key = array_pop($pathParts);
     $respStatus = 200;
     $respHeaders = array('X-Powered-By' => \Ratchet\VERSION, 'Access-Control-Allow-Origin' => '*');
     $respBody = null;
     switch ($action) {
         case 'id':
             $respHeaders['Content-Type'] = 'text/html';
             if ($peerId === null) {
                 do {
                     $peerId = substr(sha1(uniqid('', true) . mt_rand()), 0, self::PEERID_LENGTH);
                 } while ($this->peerServer->peerIdExists($peerId));
             }
             $respBody = $peerId;
             break;
         case 'peers':
             if (self::ALLOW_DISCOVERY) {
                 $peers = $this->peerServer->listPeers();
                 $list = array();
                 foreach ($peers as $peer) {
                     $list[] = $peer['id'];
                 }
                 $respBody = $list;
             } else {
                 $respStatus = 401;
                 // Access denied
             }
             break;
         case 'offer':
         case 'candidate':
         case 'answer':
         case 'leave':
             //TODO: start streaming?
         //TODO: start streaming?
         default:
             $respStatus = 400;
             //Bad request
     }
     if (is_array($respBody)) {
         // Encode to JSON
         $respHeaders['Content-Type'] = 'application/json';
         $respBody = json_encode($respBody);
     }
     //Send response
     $response = new Response($respStatus, $respHeaders, (string) $respBody);
     $from->send((string) $response);
     $from->close();
 }
开发者ID:mtobbias,项目名称:GuaranaOS,代码行数:58,代码来源:PeerHttpServer.class.php


示例2: setHeaders

 /**
  * @param RequestInterface $request
  *
  * @return RequestInterface
  */
 private function setHeaders(RequestInterface $request)
 {
     foreach ($this->headers as $name => $value) {
         $request->setHeader($name, $value);
     }
     return $request;
 }
开发者ID:erliz,项目名称:jira-api-client-guzzle-provider,代码行数:12,代码来源:Client.php


示例3: getCacheKey

 /**
  * {@inheritdoc}
  */
 public function getCacheKey(RequestInterface $request)
 {
     // See if the key has already been calculated
     $key = $request->getParams()->get(self::CACHE_KEY);
     if (!$key) {
         $cloned = clone $request;
         $cloned->removeHeader('Cache-Control');
         // Check to see how and if the key should be filtered
         foreach (explode(';', $request->getParams()->get(self::CACHE_KEY_FILTER)) as $part) {
             $pieces = array_map('trim', explode('=', $part));
             if (isset($pieces[1])) {
                 foreach (array_map('trim', explode(',', $pieces[1])) as $remove) {
                     if ($pieces[0] == 'header') {
                         $cloned->removeHeader($remove);
                     } elseif ($pieces[0] == 'query') {
                         $cloned->getQuery()->remove($remove);
                     }
                 }
             }
         }
         $raw = (string) $cloned;
         $key = 'GZ' . md5($raw);
         $request->getParams()->set(self::CACHE_KEY, $key)->set(self::CACHE_KEY_RAW, $raw);
     }
     return $key;
 }
开发者ID:Frinstio,项目名称:AlfredWorkflow.com,代码行数:29,代码来源:DefaultCacheKeyProvider.php


示例4: visit

 public function visit(CommandInterface $command, RequestInterface $request, Parameter $param, $value)
 {
     $this->fqname = $command->getName();
     $query = array();
     $this->customResolver($value, $param, $query, $param->getWireName());
     $request->addPostFields($query);
 }
开发者ID:loulancn,项目名称:core,代码行数:7,代码来源:AwsQueryVisitor.php


示例5: addQueryString

 private function addQueryString(array $queryString, RequestInterface $request)
 {
     ksort($queryString);
     foreach ($queryString as $key => $value) {
         $request->getQuery()->set($key, $value);
     }
 }
开发者ID:CHANDRA-BHUSHAN-SAH,项目名称:stormpath-sdk-php,代码行数:7,代码来源:HttpClientRequestExecutor.php


示例6: after

public function after(CommandInterface $command, RequestInterface $request)
{
$xml = null;


 if (isset($this->data[$command])) {
$xml = $this->finishDocument($this->data[$command]);
unset($this->data[$command]);
} else {

 $operation = $command->getOperation();
if ($operation->getData('xmlAllowEmpty')) {
$xmlWriter = $this->createRootElement($operation);
$xml = $this->finishDocument($xmlWriter);
}
}

if ($xml) {

 if ($this->contentType && !$request->hasHeader('Content-Type')) {
$request->setHeader('Content-Type', $this->contentType);
}
$request->setBody($xml);
}
}
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:25,代码来源:XmlVisitor.php


示例7: onOpen

 /**
  * {@inheritdoc}
  */
 public function onOpen(ConnectionInterface $conn, RequestInterface $request = null)
 {
     if (null === $request) {
         throw new \UnexpectedValueException('$request can not be null');
     }
     $context = $this->_matcher->getContext();
     $context->setMethod($request->getMethod());
     $context->setHost($request->getHost());
     try {
         $parameters = $this->_matcher->match($request->getPath());
     } catch (MethodNotAllowedException $nae) {
         return $this->close($conn, 403);
     } catch (ResourceNotFoundException $nfe) {
         return $this->close($conn, 404);
     }
     if ($parameters['_controller'] instanceof ServingCapableInterface) {
         $parameters['_controller']->serve($conn, $request, $parameters);
     } else {
         $query = array();
         foreach ($query as $key => $value) {
             if (is_string($key) && '_' !== substr($key, 0, 1)) {
                 $query[$key] = $value;
             }
         }
         $url = Url::factory($request->getPath());
         $url->setQuery($query);
         $request->setUrl($url);
         $conn->controller = $parameters['_controller'];
         $conn->controller->onOpen($conn, $request);
     }
 }
开发者ID:owlycode,项目名称:reactboard,代码行数:34,代码来源:RachetRouter.php


示例8: factory

 /**
  * Simple exception factory for creating Intercom standardised exceptions
  *
  * @param RequestInterface $request The Request
  * @param Response $response The response
  * @return BadResponseException
  */
 public static function factory(RequestInterface $request, Response $response)
 {
     if (!static::isValidIntercomError($response->json())) {
         $label = 'Unsuccessful response';
         $class = __CLASS__;
     } elseif ($response->isClientError()) {
         $label = 'Client error response';
         $class = __NAMESPACE__ . '\\ClientErrorResponseException';
     } elseif ($response->isServerError()) {
         $label = 'Server error response';
         $class = __NAMESPACE__ . '\\ServerErrorResponseException';
     } else {
         $label = 'Unsuccessful response';
         $class = __CLASS__;
     }
     $message = $label . PHP_EOL . implode(PHP_EOL, array('[status code] ' . $response->getStatusCode(), '[reason phrase] ' . $response->getReasonPhrase(), '[url] ' . $request->getUrl()));
     $e = new $class($message);
     $e->setResponse($response);
     $e->setRequest($request);
     // Sets the errors if the error response is the standard Intercom error type
     if (static::isValidIntercomError($response->json())) {
         $e->setErrors($response->json()['errors']);
     }
     return $e;
 }
开发者ID:atlir,项目名称:intercom-php,代码行数:32,代码来源:IntercomException.php


示例9: signRequest

 /**
  * Always add a x-amz-content-sha-256 for data integrity.
  */
 public function signRequest(RequestInterface $request, CredentialsInterface $credentials)
 {
     if (!$request->hasHeader('x-amz-content-sha256')) {
         $request->setHeader('x-amz-content-sha256', $this->getPresignedPayload($request));
     }
     parent::signRequest($request, $credentials);
 }
开发者ID:sonijoy,项目名称:my_repo,代码行数:10,代码来源:S3SignatureV4.php


示例10: signRequest

 /**
  * Always add a x-amz-content-sha-256 for data integrity.
  */
 public function signRequest(RequestInterface $request, CredentialsInterface $credentials)
 {
     if ($request instanceof EntityEnclosingRequestInterface && $request->getBody() && !$request->hasHeader('x-amz-content-sha256')) {
         $request->setHeader('X-Amz-Content-Sha256', $this->getPresignedPayload($request));
     }
     parent::signRequest($request, $credentials);
 }
开发者ID:im286er,项目名称:ent,代码行数:10,代码来源:S3SignatureV4.php


示例11: factory

 /**
  * Simple exception factory for creating Intercom standardised exceptions
  *
  * @param RequestInterface $request The Request
  * @param Response $response The response
  * @return BadResponseException
  */
 public static function factory(RequestInterface $request, Response $response)
 {
     $response_json = $response->json();
     $intercom_unavailable_error = NULL;
     if (!static::isValidIntercomError($response_json)) {
         if ($response->isServerError()) {
             $label = 'Server error response';
             $class = __NAMESPACE__ . '\\ServerErrorResponseException';
             $intercom_unavailable_error = 'Service Unavailable: Back-end server is at capacity';
         } else {
             $label = 'Unsuccessful response';
             $class = __CLASS__;
         }
     } elseif ($response->isClientError()) {
         $label = 'Client error response';
         $class = __NAMESPACE__ . '\\ClientErrorResponseException';
     } elseif ($response->isServerError()) {
         $label = 'Server error response';
         $class = __NAMESPACE__ . '\\ServerErrorResponseException';
     } else {
         $label = 'Unsuccessful response';
         $class = __CLASS__;
     }
     $message = $label . PHP_EOL . implode(PHP_EOL, array('[status code] ' . $response->getStatusCode(), '[reason phrase] ' . $response->getReasonPhrase(), '[url] ' . $request->getUrl()));
     $e = new $class($message);
     $e->setResponse($response);
     $e->setRequest($request);
     // Sets the errors if the error response is the standard Intercom error type
     if (static::isValidIntercomError($response_json)) {
         $e->setErrors($response_json['errors']);
     } elseif ($intercom_unavailable_error != NULL) {
         $e->setErrors(array('code' => 'service_unavailable', "message" => $intercom_unavailable_error));
     }
     return $e;
 }
开发者ID:scup,项目名称:intercom-php,代码行数:42,代码来源:IntercomException.php


示例12: visit

 /**
  * {@inheritdoc}
  */
 public function visit(CommandInterface $command, RequestInterface $request, $key, $value)
 {
     if ($value instanceof PostFileInterface) {
         $request->addPostFile($value);
     } else {
         $request->addPostFile($key, $value);
     }
 }
开发者ID:jsnshrmn,项目名称:Suma,代码行数:11,代码来源:PostFileVisitor.php


示例13: onOpen

 public function onOpen(ConnectionInterface $conn, RequestInterface $request = null)
 {
     $this->log('open', $conn);
     $response = new Response(200, array('Content-type' => 'text/javascript', 'Content-Length' => $this->getFilesize($request->getPath())));
     $response->setBody($this->getContent($request->getPath()));
     $conn->send((string) $response);
     $conn->close();
 }
开发者ID:codesleeve,项目名称:guard-live-reload,代码行数:8,代码来源:HttpFileProtocol.php


示例14: sendAndProcessResponse

 /**
  * @param RequestInterface $httpRequest
  * @return EchoResponse
  */
 private function sendAndProcessResponse(RequestInterface $httpRequest)
 {
     $httpResponse = $httpRequest->send();
     $data = $httpResponse->json();
     $response = new EchoResponse($this, $data);
     $response->setVerifier($this->getVerifier());
     return $response;
 }
开发者ID:bileto,项目名称:omnipay-csob,代码行数:12,代码来源:EchoRequest.php


示例15: visit

 /**
  * {@inheritdoc}
  */
 public function visit(CommandInterface $command, RequestInterface $request, Parameter $param, $value)
 {
     if ($value instanceof PostFileInterface) {
         $request->addPostFile($value);
     } else {
         $request->addPostFile($param->getWireName(), $value);
     }
 }
开发者ID:xkeygmbh,项目名称:ifresco-php,代码行数:11,代码来源:PostFileVisitor.php


示例16: handle200Response

 protected function handle200Response(RequestInterface $request, Response $validateResponse)
 {
     $request->setResponse($validateResponse);
     if ($this->canCache->canCacheResponse($validateResponse)) {
         $this->storage->cache($request, $validateResponse);
     }
     return false;
 }
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:8,代码来源:DefaultRevalidation.php


示例17: it_raises_no_exception_on_ok_response

 public function it_raises_no_exception_on_ok_response(RequestInterface $request)
 {
     $response = new Response(200, null, '{"ok":true,"error":"something_good"}');
     $event = new Event();
     $event['request'] = $request->getWrappedObject();
     $event['response'] = $response;
     $this->shouldNotThrow('\\Guzzle\\Http\\Exception\\BadResponseException')->duringOnRequestSent($event);
 }
开发者ID:orukusaki,项目名称:slackbundle,代码行数:8,代码来源:ApiErrorSubscriberSpec.php


示例18: updateForHandle

 protected function updateForHandle(RequestInterface $request)
 {
     $that = $this;
     $request->getEventDispatcher()->addListener('request.sent', function (Event $e) use($that) {
         $that->requestHandle = $e['handle'];
     });
     return $request;
 }
开发者ID:carlesgutierrez,项目名称:libreobjet.org,代码行数:8,代码来源:CurlHandleTest.php


示例19: factory

 /**
  * Factory method to create a new Oauth exception.
  *
  * @param RequestInterface $request
  * @param Response $response
  *
  * @return OauthException
  */
 public static function factory(RequestInterface $request, Response $response)
 {
     $message = 'Client error response' . PHP_EOL . implode(PHP_EOL, array('[status code] ' . $response->getStatusCode(), '[reason phrase] ' . $response->getReasonPhrase(), '[url] ' . $request->getUrl()));
     $e = new static($message);
     $e->setResponse($response);
     $e->setRequest($request);
     return $e;
 }
开发者ID:cpliakas,项目名称:magento-client-php,代码行数:16,代码来源:OauthException.php


示例20: sendRequest

 private function sendRequest(RequestInterface $request)
 {
     try {
         return $request->send();
     } catch (\Exception $e) {
         throw new GithubException('Unexpected response.', 0, $e);
     }
 }
开发者ID:mpscholten,项目名称:github-api,代码行数:8,代码来源:AbstractApi.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Message\Response类代码示例发布时间:2022-05-23
下一篇:
PHP Message\RequestFactory类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap