Specifically, one of: General Header {@link http://tools.ietf.org/html/rfc2616#section-4.5} Request Header {@link http://tools.ietf.org/html/rfc2616#section-5.3} Response Header {@link http://tools.ietf.org/html/rfc2616#section-6.2} Entity Header {http://tools.ietf.org/html/rfc2616#section-7.1} All follow the general format given in Section 3.1 of RFC 822. {@link http://tools.ietf.org/html/rfc822#section-3.1}
See also: http://github.com/pda/phool
Author: Paul Annesley (paul@annesley.cc)
Beispiel #1
0
 /**
  * Adds an HTTP header to all requests
  * @param mixed either a string or a HeaderField
  * @return $this
  */
 public function addHeader($header)
 {
     if (is_string($header)) {
         $header = HeaderField::fromString($header);
     }
     $this->headers[] = $header;
     return $this;
 }
Beispiel #2
0
 /**
  * Parses a response into headers and a body
  */
 private function _buildResponse($response)
 {
     $sections = explode("\r\n\r\n", $response, 2);
     $body = isset($sections[1]) ? $sections[1] : NULL;
     $headers = array();
     $headerlines = explode("\n", $sections[0]);
     // process status
     list($http, $code, $message) = explode(' ', $headerlines[0], 3);
     // process headers
     foreach (array_slice($headerlines, 1) as $headerline) {
         $headers[] = HeaderField::fromString($headerline);
     }
     $response = new Response($code, $headers, $body);
     return $response;
 }
Beispiel #3
0
 public function testRoundTrip()
 {
     $string = "Test: blarg: meh\r\n";
     $this->assertEquals(Http\HeaderField::fromString($string)->__toString(), $string);
 }