Exemplo n.º 1
0
 /**
  * {@inheritDoc}
  */
 public function parse($headers, &$options = null)
 {
     $methods = HttpMethods::getValues();
     $methods = join("|", $methods);
     $regex = "~^({$methods})\\b~i";
     $parsed = [];
     $lines = preg_split("/\\R/", $headers);
     foreach ($lines as $line) {
         if (preg_match($regex, $line)) {
             $options = $line;
         } else {
             if (preg_match("~^HTTP/~", $line)) {
                 $options = $line;
             } else {
                 if (!empty($line)) {
                     list($name, $value) = preg_split("/:\\S*/", $line, 2);
                     $name = Utils::normalizeHeaderName($name);
                     $parsed[$name] = trim($value);
                 }
             }
         }
     }
     return $parsed;
 }
Exemplo n.º 2
0
 /**
  * {@inheritDoc}
  */
 public function setMethod($method)
 {
     if (!in_array($method, HttpMethods::getValues())) {
         throw new Exceptions\InvalidArgumentException("Invalid request method.");
     }
     $this->method = $method;
     return $this;
 }