Пример #1
0
 /**
  * Creates a Response object.
  *
  * @param string $status one of Spice\Http\Response\Status constants.
  * @param string $version one of Spice\Http\Version constants.
  */
 public function __construct($status = Status::OK, $httpVersion = Version::HTTP_1_1)
 {
     list($code, $phrase) = sscanf($status, "%d %s");
     $this->statusCode = (int) $code;
     $this->reasonPhrase =& $phrase;
     parent::__construct($httpVersion);
 }
Пример #2
0
 /**
  * Creates a Request object.
  *
  * @param string $uri the URI of the request
  * @param string $httpMethod [OPTIONAL] the HTTP method of the request. The default value is 'GET'
  * @param string $httpVersion [OPTIONAL] the HTTP version of the request. The default value is 'HTTP/1.1'
  */
 public function __construct($uri, $httpMethod = Method::GET, $httpVersion = Version::HTTP_1_1)
 {
     $refMethod = new \ReflectionClass('Spice\\Http\\Request\\Method');
     $constants = $refMethod->getConstants();
     if (!in_array(strtoupper($httpMethod), $constants)) {
         throw new \DomainException("Invalid HTTP method '{$httpMethod}'");
     }
     $this->uri = $uri;
     $this->method = $httpMethod;
     parent::__construct($httpVersion);
 }