예제 #1
0
 public function test_extract_auth_headers()
 {
     $parser = new ReceivedHeadersParser();
     $headers = new HttpHeaders();
     $this->assertFalse($headers->has('authorization'));
     $parser->extractAuthHeaders($headers, ['HTTP_AUTHORIZATION' => 'Bearer foo']);
     $this->assertEquals('Bearer foo', $headers->find('authorization'));
     $parser->extractAuthHeaders($headers, ['HTTP_AUTHORIZATION' => 'Bearer bar']);
     $this->assertEquals('Bearer foo', $headers->find('authorization'));
 }
예제 #2
0
파일: CookieJarTest.php 프로젝트: weew/http
 public function test_add()
 {
     $headers = new HttpHeaders(['cookie' => 'foo=bar;yolo=swag; bar=foo;']);
     $request = new HttpRequest(null, null, $headers);
     $jar = new CookieJar($request);
     $jar->set('xx', 'yy');
     $this->assertEquals(1, count($headers->get('cookie')));
     $this->assertEquals('yy', $jar->get('xx'));
     $this->assertEquals(1, count($headers->get('cookie')));
 }
예제 #3
0
 public function test_get_and_set_headers()
 {
     $response = new HttpResponse();
     $this->assertTrue($response->getHeaders() instanceof IHttpHeaders);
     $headers = new HttpHeaders();
     $headers->set('foo', 'bar');
     $response->setHeaders($headers);
     $this->assertTrue($response->getHeaders() instanceof IHttpHeaders);
     $this->assertEquals($headers->find('foo'), $response->getHeaders()->find('foo'));
     $this->assertEquals($headers->find('foo'), $response->getHeaders()->find('foo'));
     $this->assertEquals('yolo', $response->getHeaders()->find('swag', 'yolo'));
     $response->getHeaders()->set('swag', 'yolo');
     $this->assertEquals('yolo', $response->getHeaders()->find('swag'));
 }
예제 #4
0
 public function test_construct()
 {
     $headers = new HttpHeaders(['foo' => 'bar', 'bar' => ['foo', 'baz']]);
     $this->assertEquals(['foo' => ['bar'], 'bar' => ['foo', 'baz']], $headers->toArray());
 }