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


PHP Uri\Http类代码示例

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


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

示例1: setData

 public function setData($data)
 {
     if ($data instanceof Traversable) {
         $data = ArrayUtils::iteratorToArray($data);
     }
     $isAts = isset($data['atsEnabled']) && $data['atsEnabled'];
     $isUri = isset($data['uriApply']) && !empty($data['uriApply']);
     $email = isset($data['contactEmail']) ? $data['contactEmail'] : '';
     if ($isAts && $isUri) {
         $data['atsMode']['mode'] = 'uri';
         $data['atsMode']['uri'] = $data['uriApply'];
         $uri = new Http($data['uriApply']);
         if ($uri->getHost() == $this->host) {
             $data['atsMode']['mode'] = 'intern';
         }
     } elseif ($isAts && !$isUri) {
         $data['atsMode']['mode'] = 'intern';
     } elseif (!$isAts && !empty($email)) {
         $data['atsMode']['mode'] = 'email';
         $data['atsMode']['email'] = $email;
     } else {
         $data['atsMode']['mode'] = 'none';
     }
     if (!array_key_exists('job', $data)) {
         $data = array('job' => $data);
     }
     return parent::setData($data);
 }
开发者ID:utrenkner,项目名称:YAWIK,代码行数:28,代码来源:Import.php

示例2: doRequest

 /**
  * @param Request $request
  *
  * @return Response
  * @throws \Exception
  */
 public function doRequest($request)
 {
     $zendRequest = $this->application->getRequest();
     $zendResponse = $this->application->getResponse();
     $uri = new HttpUri($request->getUri());
     $queryString = $uri->getQuery();
     $method = $request->getMethod();
     if ($queryString) {
         parse_str($queryString, $query);
     }
     if ($method == HttpRequest::METHOD_POST) {
         $post = $request->getParameters();
         $zendRequest->setPost(new Parameters($post));
     } elseif ($method == HttpRequest::METHOD_GET) {
         $query = $request->getParameters();
         $zendRequest->setQuery(new Parameters($query));
     } elseif ($method == HttpRequest::METHOD_PUT) {
         $zendRequest->setContent($request->getContent());
     }
     $zendRequest->setMethod($method);
     $zendRequest->setUri($uri);
     $this->application->run();
     $this->zendRequest = $zendRequest;
     $exception = $this->application->getMvcEvent()->getParam('exception');
     if ($exception instanceof \Exception) {
         throw $exception;
     }
     $response = new Response($zendResponse->getBody(), $zendResponse->getStatusCode(), $zendResponse->getHeaders()->toArray());
     return $response;
 }
开发者ID:NaszvadiG,项目名称:ImageCMS,代码行数:36,代码来源:ZF2.php

示例3: doRequest

 /**
  * @param Request $request
  *
  * @return Response
  * @throws \Exception
  */
 public function doRequest($request)
 {
     $zendRequest = $this->application->getRequest();
     $zendResponse = $this->application->getResponse();
     $zendResponse->setStatusCode(200);
     $uri = new HttpUri($request->getUri());
     $queryString = $uri->getQuery();
     $method = strtoupper($request->getMethod());
     $zendRequest->setCookies(new Parameters($request->getCookies()));
     if ($queryString) {
         parse_str($queryString, $query);
         $zendRequest->setQuery(new Parameters($query));
     }
     if ($request->getContent() !== null) {
         $zendRequest->setContent($request->getContent());
     } elseif ($method != HttpRequest::METHOD_GET) {
         $post = $request->getParameters();
         $zendRequest->setPost(new Parameters($post));
     }
     $zendRequest->setMethod($method);
     $zendRequest->setUri($uri);
     $zendRequest->setRequestUri(str_replace('http://localhost', '', $request->getUri()));
     $zendRequest->setHeaders($this->extractHeaders($request));
     $this->application->run();
     $this->zendRequest = $zendRequest;
     $exception = $this->application->getMvcEvent()->getParam('exception');
     if ($exception instanceof \Exception) {
         throw $exception;
     }
     $response = new Response($zendResponse->getBody(), $zendResponse->getStatusCode(), $zendResponse->getHeaders()->toArray());
     return $response;
 }
开发者ID:namnv609,项目名称:Codeception,代码行数:38,代码来源:ZF2.php

示例4: ingest

 /**
  * Ingest from a URL.
  *
  * Accepts the following non-prefixed keys:
  *
  * + ingest_url: (required) The URL to ingest. The idea is that some URLs
  *   contain sensitive data that should not be saved to the database, such
  *   as private keys. To preserve the URL, remove sensitive data from the
  *   URL and set it to o:source.
  * + store_original: (optional, default true) Whether to store an original
  *   file. This is helpful when you want the media to have thumbnails but do
  *   not need the original file.
  *
  * {@inheritDoc}
  */
 public function ingest(Media $media, Request $request, ErrorStore $errorStore)
 {
     $data = $request->getContent();
     if (!isset($data['ingest_url'])) {
         $errorStore->addError('error', 'No ingest URL specified');
         return;
     }
     $uri = new HttpUri($data['ingest_url']);
     if (!($uri->isValid() && $uri->isAbsolute())) {
         $errorStore->addError('ingest_url', 'Invalid ingest URL');
         return;
     }
     $file = $this->getServiceLocator()->get('Omeka\\File');
     $file->setSourceName($uri->getPath());
     $this->downloadFile($uri, $file->getTempPath());
     $fileManager = $this->getServiceLocator()->get('Omeka\\File\\Manager');
     $hasThumbnails = $fileManager->storeThumbnails($file);
     $media->setHasThumbnails($hasThumbnails);
     if (!isset($data['store_original']) || $data['store_original']) {
         $fileManager->storeOriginal($file);
         $media->setHasOriginal(true);
     }
     $media->setFilename($file->getStorageName());
     $media->setMediaType($file->getMediaType());
     if (!array_key_exists('o:source', $data)) {
         $media->setSource($uri);
     }
 }
开发者ID:patrova,项目名称:omeka-s,代码行数:43,代码来源:Url.php

示例5: appendCdn

 protected function appendCdn($href)
 {
     $uri = new Http($href);
     if ($uri->getHost()) {
         return $href;
     }
     $servers = $this->cdnOptions['servers'];
     if (1 == count($servers)) {
         $server = $servers[0];
     } else {
         switch ($this->cdnOptions['method']) {
             case 'respective':
                 if (!isset($servers[static::$serverId])) {
                     static::$serverId = 0;
                 }
                 $server = $servers[static::$serverId];
                 static::$serverId++;
                 break;
                 // Get a random CDN server
             // Get a random CDN server
             case 'random':
             default:
                 $server = $servers[array_rand($servers)];
                 break;
         }
     }
     $href = rtrim($server, '/') . '/' . ltrim($href, '/');
     return $href;
 }
开发者ID:hoangpt,项目名称:nextcms,代码行数:29,代码来源:CdnTrait.php

示例6: getUri

 /**
  * Return the URI for this header
  *
  * @return string
  */
 public function getUri()
 {
     if ($this->uri instanceof HttpUri) {
         return $this->uri->toString();
     }
     return $this->uri;
 }
开发者ID:robertodormepoco,项目名称:zf2,代码行数:12,代码来源:AbstractLocation.php

示例7: setUri

 /**
  * @param string $uri
  *
  * @return ImageUri
  */
 public function setUri($uri)
 {
     $this->uri = new Http($uri);
     if (!$this->uri->isAbsolute()) {
         throw new \InvalidArgumentException('Invalid image URL: ' . $this->uri->toString());
     }
     return $this;
 }
开发者ID:danielcosta,项目名称:sellercenter-sdk,代码行数:13,代码来源:ImageUri.php

示例8: testAssembling

 public function testAssembling()
 {
     $uri = new HttpUri();
     $route = new Scheme('https');
     $path = $route->assemble(array(), array('uri' => $uri));
     $this->assertEquals('', $path);
     $this->assertEquals('https', $uri->getScheme());
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:8,代码来源:SchemeTest.php

示例9: isValid

 protected function isValid($value)
 {
     try {
         $uri = new Http($value);
         return $uri->isValid() && $uri->isAbsolute() && $uri->getFragment() === null;
     } catch (InvalidArgumentException $e) {
         return false;
     }
 }
开发者ID:rstgroup,项目名称:oauth2-client,代码行数:9,代码来源:RedirectUri.php

示例10: buildUrl

 protected function buildUrl($url)
 {
     if (!$this->apiKey) {
         throw new MissingAPIKeyException('Missing the API key.  Please either call setApiKey(), set the API key as a dependency parameter, or create a Magium/Mail/GeneratorConfiguration.php file to set the API key');
     }
     $uri = new Http($url);
     $uri->setQuery(['key' => $this->apiKey]);
     return $uri->toString();
 }
开发者ID:magium,项目名称:MagiumMail,代码行数:9,代码来源:Configuration.php

示例11: testAssembling

 /**
  * @dataProvider routeProvider
  * @param        Hostname $route
  * @param        string   $hostname
  * @param        array    $params
  */
 public function testAssembling(Hostname $route, $hostname, array $params = null)
 {
     if ($params === null) {
         // Data which will not match are not tested for assembling.
         return;
     }
     $uri = new HttpUri();
     $path = $route->assemble($params, array('uri' => $uri));
     $this->assertEquals('', $path);
     $this->assertEquals($hostname, $uri->getHost());
 }
开发者ID:haoyanfei,项目名称:zf2,代码行数:17,代码来源:HostnameTest.php

示例12: testShouldCache

 /**
  * @param array  $regexpes
  * @param string $uriPath
  * @param bool   $expectedResult
  * @dataProvider shouldCacheProvider
  */
 public function testShouldCache($regexpes, $uriPath, $expectedResult)
 {
     $this->strategy->setRegexpes($regexpes);
     $mvcEvent = new MvcEvent();
     $request = new HttpRequest();
     $uri = new Http();
     $uri->setPath($uriPath);
     $request->setUri($uri);
     $mvcEvent->setRequest($request);
     $this->assertEquals($expectedResult, $this->strategy->shouldCache($mvcEvent));
 }
开发者ID:stefanorg,项目名称:zf2-fullpage-cache,代码行数:17,代码来源:UriPathTest.php

示例13: testUseRequestBaseUrl

 public function testUseRequestBaseUrl()
 {
     $this->configureRoute();
     $httpUri = new HttpUri();
     $httpUri->setScheme('http');
     $httpUri->setHost('use-request-uri.com');
     $request = $this->serviceManager->get('Request');
     $request->setUri($httpUri);
     $request->setBaseUrl('/another/base/url/');
     $baseUrl = $this->factory->getBaseUrl($this->serviceManager);
     $this->assertEquals('http://use-request-uri.com/another/base/url/scn-social-auth/hauth', $baseUrl);
 }
开发者ID:aapthi,项目名称:video-collections,代码行数:12,代码来源:HybridAuthFactoryTest.php

示例14: ingest

 public function ingest(Media $media, Request $request, ErrorStore $errorStore)
 {
     $data = $request->getContent();
     if (!isset($data['o:source'])) {
         $errorStore->addError('o:source', 'No IIIF Image URL specified');
         return;
     }
     $source = $data['o:source'];
     //Make a request and handle any errors that might occur.
     $uri = new HttpUri($source);
     if (!($uri->isValid() && $uri->isAbsolute())) {
         $errorStore->addError('o:source', "Invalid url specified");
         return false;
     }
     $client = $this->getServiceLocator()->get('Omeka\\HttpClient');
     $client->setUri($uri);
     $response = $client->send();
     if (!$response->isOk()) {
         $errorStore->addError('o:source', sprintf("Error reading %s: %s (%s)", $type, $response->getReasonPhrase(), $response->getStatusCode()));
         return false;
     }
     $IIIFData = json_decode($response->getBody(), true);
     if (!$IIIFData) {
         $errorStore->addError('o:source', 'Error decoding IIIF JSON');
         return;
     }
     //Check if valid IIIF data
     if ($this->validate($IIIFData)) {
         $media->setData($IIIFData);
         // Not IIIF
     } else {
         $errorStore->addError('o:source', 'URL does not link to IIIF JSON');
         return;
     }
     //Check API version and generate a thumbnail
     //Version 2.0
     if (isset($IIIFData['@context']) && $IIIFData['@context'] == 'http://iiif.io/api/image/2/context.json') {
         $URLString = '/full/full/0/default.jpg';
         // Earlier versions
     } else {
         $URLString = '/full/full/0/native.jpg';
     }
     if (isset($IIIFData['@id'])) {
         $fileManager = $this->getServiceLocator()->get('Omeka\\File\\Manager');
         $file = $this->getServiceLocator()->get('Omeka\\File');
         $this->downloadFile($IIIFData['@id'] . $URLString, $file->getTempPath());
         $hasThumbnails = $fileManager->storeThumbnails($file);
         if ($hasThumbnails) {
             $media->setFilename($file->getStorageName());
             $media->setHasThumbnails(true);
         }
     }
 }
开发者ID:patrova,项目名称:omeka-s,代码行数:53,代码来源:IIIF.php

示例15: __invoke

 public function __invoke()
 {
     $request = $this->getController()->getRequest();
     if ('https' === $request->getUri()->getScheme()) {
         return;
     }
     // Not secure, create full url
     $plugin = $this->getController()->url();
     $url = $plugin->fromRoute(null, array(), array('force_canonical' => true), true);
     $url = new HttpUri($url);
     $url->setScheme('https');
     return $this->getController()->redirect()->toUrl($url);
 }
开发者ID:JonathanConner,项目名称:SocialNet,代码行数:13,代码来源:ForceHttps.php


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