Example #1
0
 /**
  *
  */
 protected function parseHeader($rawHeader)
 {
     $lines = explode("\r\n", $rawHeader);
     preg_match('/^http\\/(1\\.0|1\\.1)/i', array_shift($lines), $matches);
     $this->protocolVersion = $matches[1];
     $headers = [];
     foreach ($lines as $line) {
         $header = explode(':', $line, 2);
         $headerName = Headers::processName($header[0]);
         $headers[$headerName] = trim($header[1]);
     }
     $this->setHeaders($headers);
 }
Example #2
0
 public function test()
 {
     $raw = ['foo' => 'foo', 'foo-bar' => 'foo-bar'];
     $headers = new Headers($raw);
     $this->assertSame(['Foo' => 'foo', 'Foo-Bar' => 'foo-bar'], $headers->toArray());
     $this->assertTrue($headers->has('foo'));
     $this->assertTrue($headers->has('Foo'));
     $this->assertFalse($headers->has('bar'));
     $this->assertSame('foo', $headers->get('Foo'));
     $headers->remove('Foo');
     $this->assertFalse($headers->has('foo'));
     $this->assertSame('Foo-Bar: foo-bar', $headers->getLine('foo-bar'));
     $this->assertSame(['Foo-Bar: foo-bar'], $headers->getLines());
     $this->assertSame('Foo-Bar: foo-bar', $headers->toString());
     $this->assertNull($headers->getLine('non-existing'));
 }