public function __construct($url = NULL, $query = NULL) { if ($query) { $url = $url . '?' . Tuffy_Util::buildQuery($query); } $this->ch = curl_init($url); }
/** * Expands a URL. Absolute URLs, and URLs with a leading slash, * are returned as is, but relative URLs are treated as relative to * REQUEST_PREFIX instead of the current directory. * * @param string $target The URL to redirect to. * @param array $params GET parameters to include in the built URL's * query string. * @param boolean $forceHTTPS If this is TRUE, the generated URL will * always begin with https://. Otherwise, it will be the same as the * current request's scheme. */ public static function url($target, $params = NULL, $forceHTTPS = FALSE) { $scheme = $forceHTTPS ? 'https://' : REQUEST_SCHEME; if ($target === 'index') { $base = $scheme . REQUEST_HOST . REQUEST_PREFIX; } else { if (parse_url($target, PHP_URL_SCHEME) !== NULL) { $base = $target; } else { if ($target[0] === '/') { $base = $scheme . REQUEST_HOST . $target; } else { $base = $scheme . REQUEST_HOST . REQUEST_PREFIX . $target; } } } return $params === NULL ? $base : $base . '?' . Tuffy_Util::buildQuery($params, TRUE); }