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


PHP Request::getUriString方法代码示例

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


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

示例1: testRequestCanSetAndRetrieveUri

 /**
  * @dataProvider uriDataProvider
  */
 public function testRequestCanSetAndRetrieveUri($uri)
 {
     $request = new Request();
     $request->setUri($uri);
     $this->assertEquals($uri, $request->getUri());
     $this->assertInstanceOf('Zend\\Uri\\Uri', $request->getUri());
     $this->assertEquals($uri, $request->getUri()->toString());
     $this->assertEquals($uri, $request->getUriString());
 }
开发者ID:navassouza,项目名称:zf2,代码行数:12,代码来源:RequestTest.php

示例2: fromZend

 /**
  * Convert a Zend\Http\Response in a PSR-7 response, using zend-diactoros
  *
  * @param  ZendRequest $zendRequest
  * @return ServerRequest
  */
 public static function fromZend(ZendRequest $zendRequest)
 {
     $body = new Stream('php://memory', 'wb+');
     $body->write($zendRequest->getContent());
     $headers = empty($zendRequest->getHeaders()) ? [] : $zendRequest->getHeaders()->toArray();
     $query = empty($zendRequest->getQuery()) ? [] : $zendRequest->getQuery()->toArray();
     $post = empty($zendRequest->getPost()) ? [] : $zendRequest->getPost()->toArray();
     $files = empty($zendRequest->getFiles()) ? [] : $zendRequest->getFiles()->toArray();
     $request = new ServerRequest([], self::convertFilesToUploaded($files), $zendRequest->getUriString(), $zendRequest->getMethod(), $body, $headers);
     $request = $request->withQueryParams($query);
     return $request->withParsedBody($post);
 }
开发者ID:MidnightDesign,项目名称:zend-psr7bridge,代码行数:18,代码来源:Psr7ServerRequest.php

示例3: execute

 protected function execute($url, $method, array $query = null, array $rawdata = null, Headers $headers = null)
 {
     $request = new Request();
     // Headers
     $request->getHeaders()->addHeaders(array('Content-Type' => $this->getContentType()));
     if ($headers) {
         $request->getHeaders()->addHeaders($headers);
     }
     // Query
     if ($query) {
         $request->setQuery(new Parameters($query));
     }
     $request->setUri($url)->setMethod($method);
     switch ($method) {
         case self::HTTP_VERB_POST:
         case self::HTTP_VERB_PUT:
         case self::HTTP_VERB_PATCH:
             if ($rawdata) {
                 $request->setPost(new Parameters($rawdata));
             }
             break;
     }
     $client = new HttpClient('', $this->_httpClientOptions);
     $adapter = $client->getAdapter();
     /* @var $adapter Curl */
     $secure = $request->getUri()->getScheme() == 'https';
     $adapter->connect($request->getUri()->getHost(), $request->getUri()->getPort(), $secure);
     $ch = $adapter->getHandle();
     // Set URL
     curl_setopt($ch, CURLOPT_URL, $request->getUriString() . '?' . $request->getQuery()->toString());
     // ensure correct curl call
     $curlValue = true;
     switch ($method) {
         case 'GET':
             $curlMethod = CURLOPT_HTTPGET;
             break;
         case 'POST':
             $curlMethod = CURLOPT_POST;
             break;
         case 'PUT':
         case 'PATCH':
         case 'DELETE':
         case 'OPTIONS':
         case 'TRACE':
         case 'HEAD':
             $curlMethod = CURLOPT_CUSTOMREQUEST;
             $curlValue = $method;
             break;
         default:
             // For now, through an exception for unsupported request methods
             throw new Exception("Method '{$method}' currently not supported");
     }
     // mark as HTTP request and set HTTP method
     curl_setopt($ch, CURL_HTTP_VERSION_1_1, true);
     curl_setopt($ch, $curlMethod, $curlValue);
     // ensure actual response is returned
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     // set callback function
     if ($this->getCallbackWriteFunction() instanceof \Closure) {
         curl_setopt($ch, CURLOPT_WRITEFUNCTION, $this->getCallbackWriteFunction());
     }
     // ensure headers are also returned
     curl_setopt($ch, CURLOPT_HEADER, false);
     // set callback function
     if ($this->getCallbackHeaderFunction() instanceof \Closure) {
         curl_setopt($ch, CURLOPT_HEADERFUNCTION, $this->getCallbackHeaderFunction());
     }
     // Treating basic auth headers in a special way
     if ($request->getHeaders() instanceof Headers) {
         $headersArray = $request->getHeaders()->toArray();
         if (array_key_exists('Authorization', $headersArray) && 'Basic' == substr($headersArray['Authorization'], 0, 5)) {
             curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
             curl_setopt($ch, CURLOPT_USERPWD, base64_decode(substr($headersArray['Authorization'], 6)));
             unset($headersArray['Authorization']);
         }
         // set additional headers
         if (!isset($headersArray['Accept'])) {
             $headersArray['Accept'] = '';
         }
         $curlHeaders = array();
         foreach ($headersArray as $key => $value) {
             $curlHeaders[] = $key . ': ' . $value;
         }
         curl_setopt($ch, CURLOPT_HTTPHEADER, $curlHeaders);
     }
     // POST body
     switch ($method) {
         case 'POST':
         case 'PUT':
         case 'PATCH':
             curl_setopt($ch, CURLOPT_POSTFIELDS, $request->getPost()->toArray());
             break;
     }
     $this->_handlers[uniqid()] = $ch;
     end($this->_handlers);
     return key($this->_handlers);
 }
开发者ID:itscaro,项目名称:zf2-restful,代码行数:97,代码来源:ClientMulti.php

示例4: getAction

 /**
  * Get REST action
  * 
  * @author Stoyan Rangelov
  * @param \Zend\Http\Request $request
  * @return string
  */
 public function getAction(\Zend\Http\Request $request)
 {
     if ($request->isGet()) {
         $explodedURI = explode('/', $request->getUriString());
         $lastElement = end($explodedURI);
         if ($lastElement != 0) {
             $action = 'get';
         } else {
             $action = 'getList';
         }
     } else {
         if ($request->isPost()) {
             $action = 'create';
         } else {
             if ($request->isPut()) {
                 $action = 'update';
             } else {
                 if ($request->isDelete()) {
                     $action = 'delete';
                 }
             }
         }
     }
     return $action;
 }
开发者ID:EngrHaiderAli,项目名称:incoverage-backend,代码行数:32,代码来源:Permission.php


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