You are here

public function Request::getRequestTarget in Lockr 7.3

Retrieves the message's request target.

Retrieves the message's request-target either as it will appear (for clients), as it appeared at request (for servers), or as it was specified for the instance (see withRequestTarget()).

In most cases, this will be the origin-form of the composed URI, unless a value was provided to the concrete implementation (see withRequestTarget() below).

If no URI is available, and no request-target has been specifically provided, this method MUST return the string "/".

Return value

string

Overrides RequestInterface::getRequestTarget

File

vendor/guzzlehttp/psr7/src/Request.php, line 57

Class

Request
PSR-7 request implementation.

Namespace

GuzzleHttp\Psr7

Code

public function getRequestTarget() {
  if ($this->requestTarget !== null) {
    return $this->requestTarget;
  }
  $target = $this->uri
    ->getPath();
  if ($target == '') {
    $target = '/';
  }
  if ($this->uri
    ->getQuery() != '') {
    $target .= '?' . $this->uri
      ->getQuery();
  }
  return $target;
}