/** * Initializes this HTTP request. * * Throws an exception in case of invalid parameters. * * @param \Ableron\Lib\Net\Uri|null $uri URI of this request * @param string $method Method of this request * @param string|null $httpVersion HTTP version of this request * @param \Ableron\Lib\Stdlib\Interfaces\HeaderFieldInterface[] $headerFields Header fields of this request * @param array $queryParameters Set of query parameters * @param array $postParameters Set of post parameters * @param \Ableron\Lib\Http\HttpCookie[] $cookies Cookies of this request * @throws \Ableron\Core\Exception\SystemException */ public function __construct(Uri $uri = null, $method = self::METHOD_GET, $httpVersion = null, $headerFields = array(), $queryParameters = array(), $postParameters = array(), $cookies = array()) { try { // execute parent constructor parent::__construct($httpVersion, $headerFields, $cookies); // initialize query/post parameters $this->queryParameters = new OrderedMap($queryParameters); $this->postParameters = new OrderedMap($postParameters); // handle initial parameters $this->setUri($uri); $this->setMethod($method); } catch (SystemException $e) { throw new SystemException('Unable to initialize HttpRequest', 0, E_USER_NOTICE, __FILE__, __LINE__, $e); } }
/** * Initializes this HTTP response. * * Throws an exception in case of invalid parameters. * * @param int|null $statusCode The status code of this response * @param \Ableron\Lib\Net\InternetMediaType|null $contentType The content type of this response * @param string $content The content of this response * @param string|null $httpVersion HTTP version of this response * @param \Ableron\Lib\Stdlib\Interfaces\HeaderFieldInterface[] $headerFields Header fields of this response * @param \Ableron\Lib\Http\HttpCookie[] $cookies Cookies of this HTTP message * @throws \Ableron\Core\Exception\SystemException */ public function __construct($statusCode = null, InternetMediaType $contentType = null, $content = '', $httpVersion = null, $headerFields = array(), $cookies = array()) { try { // execute parent constructor parent::__construct($httpVersion, $headerFields, $cookies); // handle initial parameters if ($statusCode !== null) { $this->setStatusCode($statusCode); } if ($contentType !== null) { $this->setContentType($contentType); } $this->setContent($content); } catch (SystemException $e) { throw new SystemException('Unable to initialize HttpResponse', 0, E_USER_NOTICE, __FILE__, __LINE__, $e); } }