public function Request::setUrl

Set the URL of the request

Warning: Calling this method will modify headers, rewrite the query string object, and set other data associated with the request.

Parameters

string $url|Url Full URL to set including query string:

Return value

RequestInterface

Overrides RequestInterface::setUrl

1 call to Request::setUrl()
Request::__construct in drupal/core/vendor/guzzle/http/Guzzle/Http/Message/Request.php
Create a new request

File

drupal/core/vendor/guzzle/http/Guzzle/Http/Message/Request.php, line 232

Class

Request
HTTP request class to send requests

Namespace

Guzzle\Http\Message

Code

public function setUrl($url) {
  if ($url instanceof Url) {
    $this->url = $url;
  }
  else {
    $this->url = Url::factory($url);
  }

  // Update the port and host header
  $this
    ->setPort($this->url
    ->getPort());
  if ($this->url
    ->getUsername() || $this->url
    ->getPassword()) {
    $this
      ->setAuth($this->url
      ->getUsername(), $this->url
      ->getPassword());

    // Remove the auth info from the URL
    $this->url
      ->setUsername(null);
    $this->url
      ->setPassword(null);
  }
  return $this;
}