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


PHP Request::setHost方法代码示例

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


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

示例1: testGetUrlFormatsAUrl

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

示例2: build

 /**
  * @param ConfigurationInterface $configuration
  * @param PayURequestInterface   $request
  *
  * @return Request
  */
 public function build(ConfigurationInterface $configuration, PayURequestInterface $request)
 {
     $curlRequest = new Request();
     if (PayURequestInterface::METHOD_POST === $request->getMethod()) {
         $curlRequest->setContent($this->serializer->toJson($request->getDataObject()));
     }
     $curlRequest->setHost(sprintf('%s://%s/', $configuration->getProtocol(), $configuration->getDomain()));
     $curlRequest->setResource(sprintf('%s/%s/%s', $configuration->getPath(), $configuration->getVersion(), $request->getPath()));
     $curlRequest->setMethod($request->getMethod());
     $this->addHeaders($curlRequest, $configuration);
     return $curlRequest;
 }
开发者ID:krzysztof-gzocha,项目名称:payu,代码行数:18,代码来源:CurlRequestBuilder.php

示例3: testAddCookieHeadersAddsCookieHeaders

 public function testAddCookieHeadersAddsCookieHeaders()
 {
     $request = new Message\Request();
     $request->setHost('http://www.example.com');
     $cookie = new Cookie();
     $cookie->setName('SESSION');
     $cookie->setValue('asdf');
     $cookie->setAttribute(Cookie::ATTR_DOMAIN, '.example.com');
     $jar = new CookieJar();
     $jar->setCookies(array($cookie));
     $jar->addCookieHeaders($request);
     $this->assertEquals('SESSION=asdf', $request->getHeader('Cookie'));
 }
开发者ID:ChazalFlorian,项目名称:enjoyPangolin,代码行数:13,代码来源:CookieJarTest.php

示例4: shouldAllowFactoryHttpExceptionFromRequestAndResponse

 /**
  * @test
  */
 public function shouldAllowFactoryHttpExceptionFromRequestAndResponse()
 {
     $request = new Request();
     $request->setHost('http://example.com');
     $request->setResource('/foobar');
     $response = new Response();
     $response->setHeaders(array('HTTP/1.1 404 Not Found'));
     $httpException = HttpException::factory($request, $response);
     $this->assertInstanceOf('Payum\\Core\\Exception\\Http\\HttpException', $httpException);
     $this->assertSame($request, $httpException->getRequest());
     $this->assertSame($response, $httpException->getResponse());
     $this->assertEquals("Client error response\n[status code] 404\n[reason phrase] Not Found\n[url] http://example.com/foobar", $httpException->getMessage());
     $this->assertEquals(404, $httpException->getCode());
 }
开发者ID:sanchojaf,项目名称:oldmytriptocuba,代码行数:17,代码来源:HttpExceptionTest.php

示例5: request

 /**
  * Helper to send requests to Metrics API.
  *
  * @param string $path Path after metrics api version.
  * @param string $method HTTP Mthod, 'GET' or 'POST'.
  * @param array<string,array> $data Metrics data.
  *
  * @return stdClass
  */
 protected function request($path, $method, array $data = array())
 {
     $request = new Request();
     $response = new Response();
     $transport = $this->getTransport();
     $request->setMethod($method);
     $request->setResource($this->buildPath($path));
     $request->setHost(self::URI);
     $request->addHeader('Authorization: Basic ' . base64_encode($this->getAuthCredentials()));
     $request->addHeader('User-Agent: ' . $this->getUserAgent());
     if (count($data)) {
         $request->addHeader('Content-Type: application/json');
         $request->setContent(json_encode($data));
     }
     $transport->send($request, $response);
     return json_decode($response->getContent());
 }
开发者ID:nesQuick,项目名称:PHP-Metrics-Client,代码行数:26,代码来源:Client.php

示例6: testDigestAuthHeader

 public function testDigestAuthHeader()
 {
     $request = new Message\Request();
     $request->setMethod('GET');
     $request->setResource('/auth-digest');
     $request->setHost('http://test.webdav.org');
     $request->setProtocolVersion('1.1');
     $response = new Message\Response();
     $response->setHeaders(array("Date: Wed, 24 Jun 2015 21:49:39 GMT", "Server: Apache/2.0.54 (Debian GNU/Linux) DAV/2 SVN/1.3.2", "WWW-Authenticate: Digest realm=\"test\", nonce=\"5PvRe0oZBQA=874ad6aea3519069f30dfc704e594dde6e01b2a6\", algorithm=MD5, domain=\"/auth-digest/\", qop=\"auth\"", "Content-Length: 401", "Content-Type: text/html; charset=iso-8859-1"));
     $response->setContent("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>401 Authorization Required</title>\n</head><body>\n<h1>Authorization Required</h1>\n<p>This server could not verify that you\nare authorized to access the document\nrequested.  Either you supplied the wrong\ncredentials (e.g., bad password), or your\nbrowser doesn\\'t understand how to supply\nthe credentials required.</p>\n</body></html>");
     // Simulate the First Request/Response, where the server returns 401
     $listener = new DigestAuthListener('user1', 'user1');
     $listener->preSend($request);
     $listener->postSend($request, $response);
     // Simulate sending the second Request using the calculated Authorization Header
     $request = new Message\Request();
     $request->setMethod('GET');
     $request->setResource('/auth-digest');
     $request->setHost('http://test.webdav.org');
     $request->setProtocolVersion('1.1');
     $this->assertEmpty($request->getHeader('Authorization'));
     $listener->preSend($request);
     $this->assertEquals('Digest username="user1", realm="test", nonce="5PvRe0oZBQA=874ad6aea3519069f30dfc704e594dde6e01b2a6", response="b2cf05a5d3f51d84a8866309aed6cb5d", uri="/auth-digest"', $request->getHeader('Authorization'));
 }
开发者ID:raphydev,项目名称:onep,代码行数:24,代码来源:DigestAuthListenerTest.php

示例7: getUserInfo

 /**
  * Gets an info of user by the access token.
  *
  * @param string $token The access token
  *
  * @return UserInfo
  *
  * @throws Exception\AuthException
  * @throws Exception\NetworkException
  */
 public function getUserInfo($token)
 {
     if (empty($token)) {
         throw new \InvalidArgumentException('The access token cannot be empty.');
     }
     $request = new Request();
     $response = new Response();
     $request->setHost('https://login.yandex.ru');
     $request->setResource('/info?format=json');
     $request->addHeader('Authorization: OAuth ' . $token);
     try {
         $this->client->send($request, $response);
     } catch (ClientException $ex) {
         throw new Exception\NetworkException($ex, $request, $response);
     }
     if ($response->getStatusCode() === 200) {
         return new UserInfo($this->jsonDecode($response->getContent()));
     }
     throw new Exception\AuthException('Could not fetch user info. Reason: ' . $response->getContent(), $response->getStatusCode());
 }
开发者ID:biplane,项目名称:yandex-direct,代码行数:30,代码来源:Authenticator.php

示例8: testMatchesRequestChecksSecureAttribute

 public function testMatchesRequestChecksSecureAttribute()
 {
     $request = new Message\Request();
     $request->setHost('https://example.com');
     $cookie = new Cookie();
     $cookie->setAttribute(Cookie::ATTR_DOMAIN, 'example.com');
     $cookie->setAttribute(Cookie::ATTR_SECURE, null);
     $this->assertTrue($cookie->matchesRequest($request));
     $request = new Message\Request();
     $request->setHost('http://example.com');
     $this->assertFalse($cookie->matchesRequest($request));
 }
开发者ID:philip,项目名称:Buzz,代码行数:12,代码来源:CookieTest.php


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