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


PHP Request::getUrl方法代码示例

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


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

示例1: request

 /**
  * @param Request $request
  * @return RawResponse
  * @throws \Exception
  */
 public function request(Request $request)
 {
     $res = $this->client->request('GET', $request->getUrl());
     if ($res->getStatusCode() == 200) {
         return new RawResponse((string) $res->getBody());
     }
     throw new \Exception('Error code', $res->getStatusCode());
 }
开发者ID:mglaman,项目名称:drupalorg-cli,代码行数:13,代码来源:Client.php

示例2: cleanupCheck

 /**
  * Cleanup the cookie support check
  */
 public function cleanupCheck()
 {
     if ($this->request->getUrl()->hasParam('_checkCookie') && isset($_COOKIE[self::CHECK_COOKIE])) {
         $requestUri = $this->request->getUrl()->without('_checkCookie');
         $this->request->getResponse()->redirectAndExit($requestUri);
     }
 }
开发者ID:trigoesrodrigo,项目名称:icingaweb2,代码行数:10,代码来源:Cookie.php

示例3: initCurl

 private function initCurl()
 {
     $this->curl = curl_init($this->request->getUrl());
     foreach ($this->request->getOptions() as $option) {
         curl_setopt($this->curl, $option[0], $option[1]);
     }
     $this->curlResponse = curl_exec($this->curl);
 }
开发者ID:phpwrapper,项目名称:curl,代码行数:8,代码来源:Response.php

示例4: match

 /**
  * Matches Request to one of defined routes
  *
  * @param Request $request
  * @return array
  * @throws NoRouteFound
  */
 public function match(Request $request)
 {
     $method = $request->getMethod();
     if (isset($this->routes[$method])) {
         foreach ((array) $this->routes[$method] as $routePattern => $routeSettings) {
             if ($this->matchRoute($request->getUrl(), $routePattern, $routeSettings) === TRUE) {
                 return $routeSettings;
             }
         }
     }
     http_response_code(404);
     throw new NoRouteFound('No routed found for method "' . $method . '" and URL "' . $request->getUrl() . '"');
 }
开发者ID:JanPetr,项目名称:AlgoliaTestAppStore,代码行数:20,代码来源:Router.php

示例5: call

 /**
  * @param Request $request
  * @return Response
  */
 public function call(Request $request)
 {
     // Create cURL
     $ch = curl_init();
     // Set-up URL
     curl_setopt($ch, CURLOPT_URL, $request->getUrl());
     // Set-up headers
     $headers = $request->getHeaders();
     array_walk($headers, function (&$item, $key) {
         $item = "{$key}: {$item}";
     });
     curl_setopt($ch, CURLOPT_HTTPHEADER, array_values($headers));
     // Set-up others
     curl_setopt_array($ch, $request->getOpts());
     // Receive result
     $result = curl_exec($ch);
     // Parse response
     $response = new Response();
     if ($result === FALSE) {
         $response->setError(curl_strerror(curl_errno($ch)));
         $response->setData(FALSE);
         $response->setCode(curl_errno($ch));
         $response->setHeaders(curl_getinfo($ch));
     } else {
         $response->setData(json_decode($result));
         $response->setCode(curl_getinfo($ch, CURLINFO_HTTP_CODE));
         $response->setHeaders(curl_getinfo($ch));
     }
     // Close cURL
     curl_close($ch);
     return $response;
 }
开发者ID:r01261,项目名称:GopayInline,代码行数:36,代码来源:Curl.php

示例6: testConstruct

 function testConstruct()
 {
     $request = new Request('GET', '/foo', ['User-Agent' => 'Evert']);
     $this->assertEquals('GET', $request->getMethod());
     $this->assertEquals('/foo', $request->getUrl());
     $this->assertEquals(['User-Agent' => ['Evert']], $request->getHeaders());
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:7,代码来源:RequestTest.php

示例7: testGetUrlFormatsAUrl

 public function testGetUrlFormatsAUrl()
 {
     $request = new Request();
     $request->setHost('http://example.com');
     $request->setResource('/resource/123');
     $this->assertEquals($request->getUrl(), 'http://example.com/resource/123');
 }
开发者ID:philip,项目名称:Buzz,代码行数:7,代码来源:RequestTest.php

示例8: execute

 public function execute(Request $request)
 {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $request->getUrl());
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
     $username = $request->getUsername();
     $password = $request->getPassword();
     if ($username && $password) {
         curl_setopt($ch, CURLOPT_USERPWD, $username . ':' . $password);
     }
     switch ($request->getMethod()) {
         case self::POST:
         case self::PUT:
             curl_setopt($ch, CURLOPT_POST, 1);
             curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($request->getParameters()));
             break;
         case self::DELETE:
             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
             break;
         case self::GET:
         default:
             break;
     }
     $result = curl_exec($ch);
     if (!$result) {
         $errorNumber = curl_errno($ch);
         $error = curl_error($ch);
         curl_close($ch);
         throw new \Exception($errorNumer . ': ' . $error);
     }
     curl_close($ch);
     return $request->getResponseTransformerImpl()->transform($result);
 }
开发者ID:ner0tic,项目名称:rest,代码行数:35,代码来源:Client.php

示例9: redirect

 /**
  * @param $destination
  */
 public function redirect($destination)
 {
     if (!isset($_SESSION)) {
         session_start();
     }
     $_SESSION['referrer'] = Request::getUrl();
     header('Location: ' . $destination, true);
     exit;
 }
开发者ID:arkuuu,项目名称:publin,代码行数:12,代码来源:Controller.php

示例10: handle

 public function handle(Request $req, Response $res) : Response
 {
     if ($this->startTime) {
         $endTime = microtime(true);
         $message = date(\DateTime::ATOM, $this->startTime) . ' ' . $req->getUrl()->getFull() . ' ' . ($endTime - $this->startTime);
         file_put_contents($this->logfile, $message, \FILE_APPEND | \LOCK_EX);
     } else {
         $this->startTime = microtime(true);
     }
 }
开发者ID:inad9300,项目名称:bed.php,代码行数:10,代码来源:TimeLogger.php

示例11: construct

 /**
  * Verify basic functionality of the request object.
  *
  * @test
  * @covers ::__construct
  * @covers ::getUrl
  * @covers ::getBody
  * @covers ::getMethod
  * @covers ::getHeaders
  *
  * @return void
  */
 public function construct()
 {
     $url = 'a url';
     $method = 'a method';
     $body = ['some' => 'data'];
     $headers = ['key' => 'value'];
     $request = new Request($url, $method, $headers, $body);
     $this->assertSame($url, $request->getUrl());
     $this->assertSame($method, $request->getMethod());
     $this->assertSame($headers, $request->getHeaders());
     $this->assertSame($body, $request->getBody());
 }
开发者ID:chadicus,项目名称:marvel-api-client,代码行数:24,代码来源:RequestTest.php

示例12: handle

 /**
  * Handle Request.
  *
  * Determines which router should be executed and hand over job to it
  *
  * @param Request $request
  *
  * @return Response
  */
 public function handle(Request $request)
 {
     $router = $this->findRouter($request->getUrl());
     if (is_null($router)) {
         return $this->getNotFoundResponse('Cannot found Controller');
     }
     /** @var Controller $controller */
     $controller = new $router['class']();
     $controller->setService('octrine', $this->configureOctrineService());
     $controller->setService('session', $this->configureSession());
     return call_user_func_array([$controller, $router['method']], [$request]);
 }
开发者ID:serkin,项目名称:blog,代码行数:21,代码来源:Application.php

示例13: __construct

 public function __construct(\Request $request, \Http\ErrorResponse $response)
 {
     $vars = array();
     $vars['url'] = $request->getUrl();
     $vars['method'] = $request->getMethod();
     $vars['module'] = $request->getModule();
     $vars['code'] = $response->getCode();
     $vars['phrase'] = $response->getPhrase();
     $vars['backtrace'] = $response->getBacktrace();
     $vars['exception'] = $response->getException();
     $this->code = $vars['code'];
     parent::__construct($vars, PHPWS_SOURCE_DIR . 'Global/Templates/Http/HtmlError.html', false);
 }
开发者ID:HaldunA,项目名称:phpwebsite,代码行数:13,代码来源:HtmlErrorView.php

示例14: parser

 /**
  * 解析路由规则表
  *+--------------
  * @param Void
  * @return Self
  */
 public function parser()
 {
     $url = $this->request->getUrl();
     if ($url) {
         //如果$uri不为空,遍历路由规则表,将$uri与每条规则表进行正则匹配,直到找到相匹配的规则信息;否则抛出异常
         foreach ($this->routes as $key => $route) {
             if (empty($route)) {
                 continue;
             }
             if (preg_match($this->matchs($route), $url, $this->matchs)) {
                 $this->active = $key;
                 break;
             }
         }
     } else {
         //获取默认路由规则,路由表最后一个
         $route = $this->routes[count($this->routes) - 1];
         if (isset($route[2])) {
             $this->matchs = $route[2];
         }
     }
     return $this;
 }
开发者ID:adawongframework,项目名称:project,代码行数:29,代码来源:Route.php

示例15: passThrough

 public function passThrough(Request $request)
 {
     $params = $request->getParameters();
     if (array_key_exists('api_key', $params)) {
         throw new \ErrorException('Request contains parameter with a reserved name: \'api_key\'');
     }
     if (array_key_exists('api_sig', $params)) {
         throw new \ErrorException('Request contains parameter with a reserved name: \'api_sig\'');
     }
     $params['api_key'] = $this->consumerKey;
     $baseString = BaseString::compute($request->getMethod(), $request->getUrl(), $params);
     $signature = base64_encode(hash_hmac('sha1', $baseString, rawurlencode($this->consumerSecret), true));
     $request->setParameter('api_key', $this->consumerKey);
     $request->setParameter('api_sig', $signature);
 }
开发者ID:jonasvr,项目名称:lockedornot,代码行数:15,代码来源:RequestSigningSession.php


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