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


PHP Response::setHeaders方法代码示例

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


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

示例1: createResponse

 private function createResponse($content, $statusCode = 200)
 {
     $response = new Response();
     $response->setContent($content);
     $response->setHeaders(array('HTTP/1.1 ' . $statusCode . ' REASON'));
     return $response;
 }
开发者ID:wjzijderveld,项目名称:youless-client,代码行数:7,代码来源:ClientSpec.php

示例2: send

 /**
  * @see Client\ClientInterface
  */
 public function send(Message\Request $request, Message\Response $response)
 {
     if (!($queued = $this->receiveFromQueue())) {
         throw new \LogicException('There are no queued responses.');
     }
     $response->setHeaders($queued->getHeaders());
     $response->setContent($queued->getContent());
 }
开发者ID:richardmiller,项目名称:Linktuesday.com,代码行数:11,代码来源:AbstractQueue.php

示例3: testCallWithNullResult

 /**
  * Driver should make an HTTP request when making an RPC call and process response corrcely if result is null.
  */
 public function testCallWithNullResult()
 {
     $httpResponse = new HttpResponse();
     $httpResponse->setHeaders(['X-PHP-Version: 6.0']);
     $httpResponse->setContent(json_encode(['jsonrpc' => '2.0', 'result' => null]));
     $this->expectHttpRequest('http://phpunit', 'POST', ['Accept: application/json', 'User-Agent: Service Bus Client', 'Content-Type: application/json'], '{"jsonrpc":"2.0","method":"add","params":{"a":10,"b":53},"id":1}', $httpResponse);
     $response = $this->driver->call($this->identity, $this->createRequest())->resolve();
     $this->assertNull($response->getValue());
 }
开发者ID:skolodyazhnyy,项目名称:service-bus,代码行数:12,代码来源:DriverTest.php

示例4: testCall

 /**
  * Driver should make an HTTP request when making an RPC call.
  */
 public function testCall()
 {
     $httpResponse = new HttpResponse();
     $httpResponse->setHeaders(['X-PHP-Version: 6.0', 'X-Message-Bus-Foo-Bar: boo', 'X-Message-Bus-Baz: 1']);
     $httpResponse->setContent(json_encode(['jsonrpc' => '2.0', 'result' => 99]));
     $this->expectHttpRequest('http://phpunit', 'POST', ['Accept: application/json', 'User-Agent: Message Bus Client', 'Content-Type: application/json', 'X-Message-To: calc', 'X-Message-Topic: add', 'X-Message-Version: 1.0', 'X-Message-Bus-Base: dec'], '{"jsonrpc":"2.0","method":"add","params":{"a":10,"b":53},"id":1}', $httpResponse);
     $response = $this->driver->call($this->location, $this->createRequest())->resolve();
     $this->assertEquals(99, $response->getValue());
     $this->assertEquals(['foo_bar' => 'boo', 'baz' => 1], $response->getHeaders());
 }
开发者ID:skolodyazhnyy,项目名称:message-bus-client,代码行数:13,代码来源:DriverTest.php

示例5: getExportResponse

 protected function getExportResponse()
 {
     $zip = new \ZipArchive();
     $zip->open($this->zipFile, $zip::CREATE);
     $zip->addFile('test/etc/diary.csv', 'diary.csv');
     $zip->close();
     $response = new Response();
     $response->setHeaders(array('HTTP/1.1 200 OK', 'Content-Type: application/zip'));
     $response->setContent(file_get_contents($this->zipFile));
     return $response;
 }
开发者ID:cmbuckley,项目名称:letterboxd-ics,代码行数:11,代码来源:CalendarTest.php

示例6: testGetAuthTokenGivenCode

 /**
  * @test
  * @dataProvider getAuthCode
  */
 public function testGetAuthTokenGivenCode($code)
 {
     $response = new Response();
     $response->setContent('{"access_token": "ea135929105c4f29a0f5117d2960926f", "expires_in": 2592000}');
     $response->setHeaders(array('HTTP/1.1 200 OK'));
     $httpClient = $this->getHttpClientMock();
     $httpClient->expects($this->once())->method('post')->with($this->equalTo('https://oauth.yandex.ru/token'), $this->anything(), $this->stringContains($code))->will($this->returnValue($response));
     $auth = new Auth('test', 'test', $httpClient);
     $token = $auth->getAuthToken($code);
     $this->assertInstanceOf('\\Yandex\\Auth\\Token', $token);
     $this->assertEquals($token->getToken(), 'ea135929105c4f29a0f5117d2960926f');
 }
开发者ID:bubblehub,项目名称:php-yandex-webmaster-api,代码行数:16,代码来源:AuthTest.php

示例7: 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

示例8: send

 /**
  * @see ClientInterface
  */
 public function send(Message\Request $request, Message\Response $response)
 {
     if ($cookieJar = $this->getCookieJar()) {
         $cookieJar->clearExpiredCookies();
         $cookieJar->addCookieHeaders($request);
     }
     $context = stream_context_create($this->getStreamContextArray($request));
     $content = file_get_contents($request->getUrl(), 0, $context);
     $response->setHeaders($http_response_header);
     $response->setContent($content);
     if ($cookieJar) {
         $cookieJar->processSetCookieHeaders($request, $response);
     }
 }
开发者ID:philip,项目名称:Buzz,代码行数:17,代码来源:FileGetContents.php

示例9: send

 /**
  * @see ClientInterface
  *
  * @throws RuntimeException If file_get_contents() fires an error
  */
 public function send(Message\Request $request, Message\Response $response)
 {
     if ($cookieJar = $this->getCookieJar()) {
         $cookieJar->clearExpiredCookies();
         $cookieJar->addCookieHeaders($request);
     }
     $context = stream_context_create($this->getStreamContextArray($request));
     $content = @file_get_contents($request->getUrl(), 0, $context);
     if (false === $content) {
         $error = error_get_last();
         throw new \RuntimeException($error['message']);
     }
     $response->setHeaders((array) $http_response_header);
     $response->setContent($content);
     if ($cookieJar) {
         $cookieJar->processSetCookieHeaders($request, $response);
     }
 }
开发者ID:kingsj,项目名称:core,代码行数:23,代码来源:FileGetContents.php

示例10: testGetHostListUrl

 /**
  * @test
  */
 public function testGetHostListUrl()
 {
     $response = new Response();
     $response->setHeaders(array('HTTP/1.1 200 OK'));
     $response->setContent('
         <service>
           <workspace>
             <collection href="https://webmaster.yandex.ru/api/123456789/hosts">
               <title>Host list</title>
             </collection>
           </workspace>
         </service>
     ');
     $httpClient = $this->getHttpClientMock();
     $httpClient->expects($this->once())->method('get')->with($this->equalTo('https://webmaster.yandex.ru/api/123456789'))->will($this->returnValue($response));
     $webmaster = new Webmaster('test', 'test', $httpClient);
     $webmaster->setToken('ea135929105c4f29a0f5117d2960926f');
     $url = $webmaster->getHostListUrl(123456789);
     $this->assertEquals($url, 'https://webmaster.yandex.ru/api/123456789/hosts');
 }
开发者ID:bubblehub,项目名称:php-yandex-webmaster-api,代码行数:23,代码来源:WebmasterTest.php

示例11: 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

示例12: invalidResultProvider

 /**
  * Invalid traction request
  */
 public function invalidResultProvider()
 {
     $response = new TransportResponse();
     $response->setHeaders(array("HTTP/1.1 200 OK", "Date: Thu, 13 Sep 2012 01:54:17 GMT", "Server: TractionPlatform", "TRAC-RESULT: 1", "TRAC-ERROR: Incorrect Login credentials", "Transfer-Encoding: chunked", "Content-Type: text/plain; charset=UTF-8"));
     return array(array($response));
 }
开发者ID:markey-magic,项目名称:tractionphp,代码行数:9,代码来源:ResponseTest.php

示例13: createResponse

 private function createResponse($statusCode = 200, $content = true)
 {
     $response = new Response();
     $response->setHeaders(array(sprintf("HTTP/1.1 %s FOOBAR", $statusCode)));
     if ($content) {
         $response->setContent($this->xml);
     }
     return $response;
 }
开发者ID:nfabre,项目名称:connect,代码行数:9,代码来源:ApiTest.php


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