You are here

public function HttpClientRequest::url in Http Client 6.2

Same name and namespace in other branches
  1. 7.2 includes/HttpClient.inc \HttpClientRequest::url()

Returns the url taken the parameters into account.

File

includes/HttpClient.inc, line 636

Class

HttpClientRequest
This is a convenience class that allows the manipulation of a http request before it's handed over to curl.

Code

public function url() {
  if (empty($this->parameters)) {
    return $this->url;
  }
  $total = array();
  foreach ($this->parameters as $k => $v) {
    if (is_array($v)) {
      foreach ($v as $va) {
        $total[] = HttpClient::urlencode_rfc3986($k) . "[]=" . HttpClient::urlencode_rfc3986($va);
      }
    }
    else {
      $total[] = HttpClient::urlencode_rfc3986($k) . "=" . HttpClient::urlencode_rfc3986($v);
    }
  }
  $out = implode("&", $total);
  return $this->url . '?' . $out;
}