* @license http://www.apache.org/licenses/LICENSE-2.0 * @link http://phpsx.org */ class Request extends Message implements RequestInterface { /** @var string */ protected $requestTarget; /** @var string */ protected $method; /** @var \PSX\Uri\UriInterface */ protected $uri; /** @var array */ protected $attributes = []; /** * @param \PSX\Uri\UriInterface $uri * @param string $method * @param array $headers * @param string $body */ public function __construct(UriInterface $uri, $method, array $headers = [], $body = null) { parent::__construct($headers, $body); $this->uri = $uri; $this->method = $method; } /** * Returns the request target * * @return string */ public function getRequestTarget() { if ($this->requestTarget !== null) { return $this->requestTarget; } $target = $this->uri->getPath(); if (empty($target)) { $target = '/'; } $query = $this->uri->getQuery(); if (!empty($query)) { $target.= '?' . $query; } return $target; } /** * Sets the request target * * @param string $requestTarget */ public function setRequestTarget($requestTarget) { $this->requestTarget = $requestTarget; } /** * Returns the request method * * @return string */ public function getMethod() { return $this->method; } /** * Sets the request method * * @param string $method */ public function setMethod($method) { $this->method = $method; } /** * Returns the request uri * * @return \PSX\Uri\UriInterface */ public function getUri() { return $this->uri; } /** * Sets the request uri * * @param \PSX\Uri\UriInterface $uri */ public function setUri(UriInterface $uri) { $this->uri = $uri; } /** * Converts the request object to an http request string * * @return string */ public function toString() { $request = Parser\RequestParser::buildStatusLine($this) . Http::NEW_LINE; $headers = Parser\RequestParser::buildHeaderFromMessage($this); foreach ($headers as $header) { $request.= $header . Http::NEW_LINE; } $request.= Http::NEW_LINE; $request.= (string) $this->getBody(); return $request; } public function getAttributes() { return $this->attributes; } public function getAttribute($name) { return isset($this->attributes[$name]) ? $this->attributes[$name] : null; } public function setAttribute($name, $value) { $this->attributes[$name] = $value; } public function removeAttribute($name) { if (isset($this->attributes[$name])) { unset($this->attributes[$name]); } } public function __toString() { return $this->toString(); } } __halt_compiler();----SIGNATURE:----NIU/iT3FreEsQoun5MDC5XMzm5eB2NCOat9Fyw/31l1WitigEjThQoomqowDL90Rpi/od7bBa+HVd+XtAscHNqMdXOJ5OPqHc1k1rLG56jlN0ZQ/L+RmPEHampuu9a+xELpZILoMnwvCKdis9bOhklmuPs7CVy36uioVwBxbJNniL+jfQzc0xqePN4dBKur3/X4heE8rxyKhxVcH8OvYvMprb71bTJwoKFd9sj5C5VPth7WkJVKvwD87Hj5si9ETN1hUP1ehvzbrluSV1Sbk1j1pPqI0l6Z63Om7E2TivxI5ISUyRcfq4YX/QjqQeaX9nqjyy37pSoKgG72Cc6PUDcuZAi5saIctA+yfRiE/vafi/AvFqgNwVNygw3RIbX8/RPYa89ZwjZt1MBx/BCoYUa+Q8I326HJFkSrgaH1S68s8xVHa6NvonZk3MIn/vlggDhKOBIju3JEd2Uav+YQ5Uyzs4HByVY4TfghhyULFhAUNOPWFjHK2n5WiFZ0uK2UwFfdkuxRQ7fCLpVLtVHmPuStkpSSGmQ59G8qTOmGpg61Ey2lX7cYnlnZl5xFyQvBgyjbCbBRRddSqzkyTrF5xP+V1865mq9giVqfeepPg/Q5ZVdfw50OsFdMphnWRnaGuMs/KKwu7GAj+Ctt0hbUhoJ5Yo+VffbimS4tJzrZ0D8w=----ATTACHMENT:----NzY4OTM4OTg4NTUzMTI3NiA0Njg4MDUxOTg0ODc3NDQgNjA5MDQ1ODc2MTY4NTk4MA==