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


PHP Request::fromUrl方法代码示例

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


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

示例1: authenticate

 /**
  * Authenticate the request object. Apply the access_token to the URL
  *
  * TODO: implement
  * 
  * @param Request       $request        Request object to authenticate
  */
 public function authenticate(\Buzz\Message\Request $request)
 {
     $url = $request->getUrl();
     $prefix = strpos($url, '?') > 0 ? '&' : '?';
     $request->fromUrl($url . $prefix . 'access_token=' . $this->accessToken);
     return $request;
 }
开发者ID:puwenhan,项目名称:github-api3-php,代码行数:14,代码来源:OAuth.php

示例2: testFromUrlRejectsInvalidUrl

 public function testFromUrlRejectsInvalidUrl()
 {
     $this->setExpectedException('InvalidArgumentException');
     // port number is too high
     $request = new Request();
     $request->fromUrl('http://localhost:123456');
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:7,代码来源:RequestTest.php

示例3: testSendToInvalidUrl

 /**
  * @dataProvider provideInvalidHosts
  */
 public function testSendToInvalidUrl($host, $client)
 {
     $this->setExpectedException('Buzz\\Exception\\ClientException');
     $request = new Message\Request();
     $request->fromUrl('http://' . $host . ':12345');
     $response = new Message\Response();
     $client = new $client();
     $client->setTimeout(0.05);
     $client->send($request, $response);
 }
开发者ID:ChazalFlorian,项目名称:enjoyPangolin,代码行数:13,代码来源:ClientTest.php

示例4: createRequest

 /**
  * Converts a PSR request into a BuzzRequest request.
  *
  * @param RequestInterface $request
  *
  * @return BuzzRequest
  */
 private function createRequest(RequestInterface $request)
 {
     $buzzRequest = new BuzzRequest();
     $buzzRequest->setMethod($request->getMethod());
     $buzzRequest->fromUrl($request->getUri()->__toString());
     $buzzRequest->setProtocolVersion($request->getProtocolVersion());
     $buzzRequest->setContent((string) $request->getBody());
     $this->addPsrHeadersToBuzzRequest($request, $buzzRequest);
     return $buzzRequest;
 }
开发者ID:php-http,项目名称:buzz-adapter,代码行数:17,代码来源:Client.php

示例5: testSendToInvalidUrl

 /**
  * @dataProvider provideInvalidHosts
  */
 public function testSendToInvalidUrl($host)
 {
     $this->setExpectedException('RuntimeException');
     $request = new Message\Request();
     $request->fromUrl('http://' . $host . ':12345');
     $response = new Message\Response();
     $client = new FileGetContents();
     $client->setTimeout(0.05);
     $client->send($request, $response);
 }
开发者ID:kingsj,项目名称:core,代码行数:13,代码来源:FileGetContentsTest.php

示例6: testAuthenticate

 public function testAuthenticate()
 {
     $basic = new OAuth('KFGDSYGSDHKKGFSFN');
     // Create request, authenticate it
     $request = new Request();
     $request->fromUrl('http://test.com?name=dsyph3r');
     $request = $basic->authenticate($request);
     // Check access_token param is set correctly
     $url = parse_url($request->getUrl());
     $params = explode('&', $url['query']);
     $this->assertContains('access_token=KFGDSYGSDHKKGFSFN', $params);
 }
开发者ID:puwenhan,项目名称:github-api3-php,代码行数:12,代码来源:OAuthTest.php

示例7: testLogger

 public function testLogger()
 {
     $test = $this;
     $logger = function ($line) use($test) {
         $test->assertRegExp('~^Sent "GET http://google.com/" in \\d+ms$~', $line);
     };
     $request = new Message\Request();
     $request->fromUrl('http://google.com/');
     $response = new Message\Response();
     $listener = new LoggerListener($logger);
     $listener->preSend($request);
     $listener->postSend($request, $response);
 }
开发者ID:kingsj,项目名称:core,代码行数:13,代码来源:LoggerListenerTest.php

示例8: doHttpRequest

 /**
  * @param $method
  * @param $relativeUrl
  * @param array|\stdClass $content
  * @return mixed
  */
 protected function doHttpRequest($method, $relativeUrl, $content = null)
 {
     $relativeUrl = ltrim($relativeUrl, '/');
     $response = new Response();
     $request = new Request($method);
     $request->fromUrl($this->baseUrl . '/' . $relativeUrl);
     $request->addHeader("Content-Type: application/json");
     $request->addHeader('Accept: application/json');
     if ($content) {
         $request->setContent(json_encode(array_filter((array) $content)));
     }
     $timezone = new \DateTimeZone("UTC");
     $datetime = new \DateTime(null, $timezone);
     $timestamp = str_replace('-', '', $datetime->format('c'));
     $nonce = uniqid();
     $authToken = $this->makeAuthHeader($request, $timestamp, $nonce);
     $request->addHeader("Authorization: " . $authToken);
     // $listener = new BasicAuthListener($this->username, $this->password);
     // $listener->preSend($request);
     $this->httpClient->send($request, $response);
     return $this->getResult($response);
 }
开发者ID:bluestatedigital,项目名称:akamai-api-client,代码行数:28,代码来源:Client.php

示例9: testMultiCurlExecutesRequestsConcurently

 public function testMultiCurlExecutesRequestsConcurently()
 {
     $client = new MultiCurl();
     $client->setTimeout(10);
     $calls = array();
     $callback = function ($client, $request, $response, $options, $error) use(&$calls) {
         $calls[] = func_get_args();
     };
     for ($i = 3; $i > 0; $i--) {
         $request = new Request();
         $request->fromUrl($_SERVER['TEST_SERVER'] . '?delay=' . $i);
         $client->send($request, new Response(), array('callback' => $callback));
     }
     $client->flush();
     $this->assertCount(3, $calls);
 }
开发者ID:ChazalFlorian,项目名称:enjoyPangolin,代码行数:16,代码来源:FunctionalTest.php

示例10: buildValidationRequest

 /**
  * @param string $credentials
  *
  * @return \Buzz\Message\Request
  */
 public function buildValidationRequest($credentials)
 {
     $request = new Request();
     $request->fromUrl(sprintf('%s&ticket=%s', $this->getValidationUrl(), $credentials));
     return $request;
 }
开发者ID:nicolasbui,项目名称:BeSimpleSsoAuthBundle,代码行数:11,代码来源:Server.php

示例11: doRequest

 /**
  * @parem string  $controller
  * @param Request $request
  * @param array   $qs
  *
  * @throws RequestException
  *
  * @return JsonResponse
  */
 protected function doRequest($controller, Request $request, array $qs = array())
 {
     $request->fromUrl($this->getApiEndpoint($controller) . '?' . http_build_query($qs));
     $request->addHeader('Authorization: Basic ' . $this->options['key']);
     $request->addHeader('Accept: text/json');
     $this->client->send($request, $response = new JsonResponse());
     $content = $response->getContentJson(true);
     if (!in_array($content['ReturnCode'], array(self::EXECCODE_SUCCESS, self::EXECCODE_OPERATION_REFUSED))) {
         $e = new RequestException(print_r(array_merge($content, array('url' => $request->getUrl(), 'content' => $request->getContent())), true));
         $e->setRequest($request);
         throw $e;
     }
     return $response;
 }
开发者ID:winzou,项目名称:limonetik-php-api,代码行数:23,代码来源:APIClient.php

示例12: testRedirectedToForbiddenProtocol

 /**
  * @expectedException RuntimeException
  * @expectedExceptionMessage Protocol pop3 not supported or disabled in libcurl
  */
 public function testRedirectedToForbiddenProtocol()
 {
     $client = new Curl();
     $request = new Request();
     $request->fromUrl($_SERVER['TEST_SERVER'] . '?redirect_to=pop3://localhost/');
     $response = $this->send($client, $request);
 }
开发者ID:luoshulin,项目名称:falcon,代码行数:11,代码来源:FunctionalTest.php

示例13: testConsecutiveRequests

 /**
  * @dataProvider provideClient
  */
 public function testConsecutiveRequests($client)
 {
     // request 1
     $request = new Request(Request::METHOD_PUT);
     $request->fromUrl($_SERVER['TEST_SERVER']);
     $request->addHeader('Content-Type: application/json');
     $request->setContent(json_encode(array('foo' => 'bar')));
     $response = new Response();
     $client->send($request, $response);
     $data = json_decode($response->getContent(), true);
     $this->assertEquals('PUT', $data['SERVER']['REQUEST_METHOD']);
     $this->assertEquals('application/json', $data['SERVER']['CONTENT_TYPE']);
     $this->assertEquals('{"foo":"bar"}', $data['INPUT']);
     // request 2
     $request = new Request(Request::METHOD_GET);
     $request->fromUrl($_SERVER['TEST_SERVER']);
     $response = new Response();
     $client->send($request, $response);
     $data = json_decode($response->getContent(), true);
     $this->assertEquals('GET', $data['SERVER']['REQUEST_METHOD']);
     $this->assertEmpty($data['INPUT']);
 }
开发者ID:kingsj,项目名称:core,代码行数:25,代码来源:FunctionalTest.php

示例14: queryByUrl

 /**
  * Return an array of Image most similar to the supplied image
  *
  * @param string $url
  * @param int $returns (optional) defaults to 12
  * @param int $sketch (optional)  0 for photograph 1 for sketch, defaults to 0
  * @param $fast (optional)
  *
  * @return array of ImgSeek\Entity\ImageInterface
  */
 public function queryByUrl($url, $returns = 12, $sketch = 0, $fast = false)
 {
     $request = new Request();
     $request->fromUrl($url);
     $response = new Response();
     $this->httpClient->send($request, $response);
     $imgResponses = $this->imgSeekGateway->request('queryImgBlob', array($this->defaultDbId, $response->getContent(), $returns, $sketch, $fast));
     $imageIds = array();
     foreach ($imgResponses as $imgResponse) {
         $imageIds[] = $imgResponse[0];
     }
     $images = array();
     foreach ($this->persistence->findImages($imageIds) as $image) {
         $imageId = $image->getImageId();
         foreach ($imgResponses as $imgResponse) {
             if ($imgResponse[0] == $imageId) {
                 $imageSet['image'] = $image;
                 $imageSet['score'] = $imgResponse[1];
                 $images[] = $imageSet;
                 continue;
             }
         }
     }
     return $images;
 }
开发者ID:iampersistent,项目名称:imgseek-php,代码行数:35,代码来源:ImgSeekManager.php

示例15: testRedirectedResponse

 /**
  * @dataProvider provideClient
  */
 public function testRedirectedResponse($client)
 {
     $request = new Request();
     $request->fromUrl($_SERVER['TEST_SERVER'] . '?redirect_to=' . $_SERVER['TEST_SERVER']);
     $response = $this->send($client, $request);
     $headers = $response->getHeaders();
     $this->assertContains('200', $headers[0]);
 }
开发者ID:Vallach,项目名称:behat-poc,代码行数:11,代码来源:FunctionalTest.php


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