public function useProxy($proxy, $type = self::PROXY_HTTP, $auth = self::AUTH_BASIC)
    {
        $proxy = (string) $proxy;

        if (!in_array($type, [self::PROXY_HTTP, self::PROXY_SOCKS5])) {
            throw new \InvalidArgumentException('The $type parameter must be one of: HttpClient::PROXY_HTTP, HttpClient::PROXY_SOCKS5.');
        }

        if (!in_array($auth, [self::AUTH_BASIC, self::AUTH_NTLM])) {
            throw new \InvalidArgumentException('The $auth parameter must be one of: HttpClient::AUTH_BASIC, HttpClient::AUTH_NTLM.');
        }

        if (strpos($proxy, '@') !== false) {
            list($proxyCredentials, $proxyAddress) = explode('@', $proxy, 2);
            curl_setopt($this->handle, CURLOPT_PROXY, $proxyAddress);
            curl_setopt($this->handle, CURLOPT_PROXYUSERPWD, $proxyCredentials);
        } else {
            curl_setopt($this->handle, CURLOPT_PROXY, $proxy);
        }
    }