* @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:----F/APuOaSJp1PCyaBeP3T6eweLAJ1pyoGSEjFCNMgeiCH1tPXpbFia5jLiMcgGXkv2Mcnq0ubZZqDxrGIztmv+2V4PoaFueHPbFOMVlFPniYu1YOr90/ELlofGfmAE7GscN/JZOsg/mcnZjc5b2fIbGfQpdzn8xMoRE+R6zLXolQM33dXvVlwFwSFrMSdozmmedAiZ3QEhkGY0ivzZJcnlB7sf2kfRh85Ul+6Qs4adsetSGke5xrGoQsIDtsWo6VSoSuPkoKtpk7hfhetYk+cXR8V37fbPd8LbDn34Hi8XERgU28qJ3U4V15U5rC9s1yrmJymxNYnuv/SQ19U1JEbbaz5pN3snUap+RadwBTR4QexDwa2WKt2PqYckIgqk+T4h6maRYx9kie6Bvlzk4b2FYtrJAgkP851WccW4Rq7cpDvbObBAo4BM0gMfK6fKyZaRg6d2PsL28QwX//HICXjo2GzHobiL8r0KsSRwVBnCrtDp5Maz83l67Jq+0kubAudmWytVEbL4jk1OgZc13po5eBNZCmLbe+VofZsFQhXIVZiIMpKE+TkPCDEgDQT86ynbnQd9F+00uD3x6pFEUK5U+55GGAseAOcbT4h3pI+9ivFGAHJwwUQCy4NS85kDdkf6jq41KKuWUm+HFen4HMPgKgFpZcGUwVOCzH39faLeVo=----ATTACHMENT:----MjMzMzExNDY1MjYyMTgzMSAxOTUyODcwNzA3NDY5MTMyIDU4NTE4NTk0OTkzODM3MzQ=