Example #1
0
 public function parseFrom($string)
 {
     $fields = explode("\r\n", Preg::replace($string, '/\\x0D\\x0A[\\x09\\x20]+/', ' '));
     //Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF
     //HTTP-Version   = "HTTP" "/" 1*DIGIT "." 1*DIGIT
     if (!Preg::match($statusLine = array_shift($fields), '|HTTP/([0-9]+\\.[0-9]+)\\s+([0-5][0-9]+)\\s+(.*)|', $match)) {
         throw new \Psc\Exception('Kann Header Status-Line nicht parsen: "' . $statusLine . '"');
     }
     list($NULL, $this->version, $this->code, $this->reason) = $match;
     parent::parseFrom($string);
 }
Example #2
0
 /**
  * @expectedException Psc\Net\HTTP\HeaderFieldNotDefinedException
  */
 public function testEmptyFieldParsing_doesThrowException()
 {
     $header = new Header();
     $header->getField('Content-Disposition', Header::PARSE);
 }