Beispiel #1
0
void LLCurl::Easy::prepRequest(const std::string& url,
							   const std::vector<std::string>& headers,
							   ResponderPtr responder, bool post)
{
	resetState();
	
	if (post) setoptString(CURLOPT_ENCODING, "");

//	setopt(CURLOPT_VERBOSE, 1); // usefull for debugging
	setopt(CURLOPT_NOSIGNAL, 1);

	if (LLSocks::getInstance()->isHttpProxyEnabled())
	{
		std::string address = LLSocks::getInstance()->getHTTPProxy().getIPString();
		U16 port = LLSocks::getInstance()->getHTTPProxy().getPort();
		setoptString(CURLOPT_PROXY, address.c_str());
		setopt(CURLOPT_PROXYPORT, port);
		if (LLSocks::getInstance()->getHttpProxyType() == LLPROXY_SOCKS)
		{
			setopt(CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
		}
		else
		{
			setopt(CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
		}
	}

	mOutput.reset(new LLBufferArray);
	setopt(CURLOPT_WRITEFUNCTION, (void*)&curlWriteCallback);
	setopt(CURLOPT_WRITEDATA, (void*)this);

	setopt(CURLOPT_READFUNCTION, (void*)&curlReadCallback);
	setopt(CURLOPT_READDATA, (void*)this);
	
	setopt(CURLOPT_HEADERFUNCTION, (void*)&curlHeaderCallback);
	setopt(CURLOPT_HEADERDATA, (void*)this);

	setErrorBuffer();
	setCA();

	setopt(CURLOPT_SSL_VERIFYPEER, true);
	setopt(CURLOPT_TIMEOUT, CURL_REQUEST_TIMEOUT);

	setoptString(CURLOPT_URL, url);

	mResponder = responder;

	if (!post)
	{
		slist_append("Connection: keep-alive");
		slist_append("Keep-alive: 300");
		// Accept and other headers
		for (std::vector<std::string>::const_iterator iter = headers.begin();
			 iter != headers.end(); ++iter)
		{
			slist_append((*iter).c_str());
		}
	}
}
Beispiel #2
0
void LLCurl::Easy::prepRequest(const std::string& url,
							   const std::vector<std::string>& headers,
							   ResponderPtr responder, S32 time_out, bool post)
{
	resetState();
	
	if (post) setoptString(CURLOPT_ENCODING, "");

	//setopt(CURLOPT_VERBOSE, 1); // useful for debugging
	setopt(CURLOPT_NOSIGNAL, 1);

	// Set the CURL options for either Socks or HTTP proxy
	LLProxy::getInstance()->applyProxySettings(this);

	mOutput.reset(new LLBufferArray);
	mOutput->setThreaded(true);
	setopt(CURLOPT_WRITEFUNCTION, (void*)&curlWriteCallback);
	setopt(CURLOPT_WRITEDATA, (void*)this);

	setopt(CURLOPT_READFUNCTION, (void*)&curlReadCallback);
	setopt(CURLOPT_READDATA, (void*)this);
	
	setopt(CURLOPT_HEADERFUNCTION, (void*)&curlHeaderCallback);
	setopt(CURLOPT_HEADERDATA, (void*)this);

	// Allow up to five redirects
	if (responder && responder->followRedir())
	{
		setopt(CURLOPT_FOLLOWLOCATION, 1);
		setopt(CURLOPT_MAXREDIRS, MAX_REDIRECTS);
	}

	setErrorBuffer();
	setCA();

	setopt(CURLOPT_SSL_VERIFYPEER, true);
	
	//don't verify host name so urls with scrubbed host names will work (improves DNS performance)
	setopt(CURLOPT_SSL_VERIFYHOST, 0);
	setopt(CURLOPT_TIMEOUT, llmax(time_out, CURL_REQUEST_TIMEOUT));

	setoptString(CURLOPT_URL, url);

	mResponder = responder;

	if (!post)
	{
		slist_append("Connection: keep-alive");
		slist_append("Keep-alive: 300");
		// Accept and other headers
		for (std::vector<std::string>::const_iterator iter = headers.begin();
			 iter != headers.end(); ++iter)
		{
			slist_append((*iter).c_str());
		}
	}
}
void LLCurl::Easy::setCA()
{
    if(!sCAPath.empty())
    {
        setoptString(CURLOPT_CAPATH, sCAPath);
    }
    if(!sCAFile.empty())
    {
        setoptString(CURLOPT_CAINFO, sCAFile);
    }
}
void LLCurl::Easy::prepRequest(const std::string& url,
                               const std::vector<std::string>& headers,
                               ResponderPtr responder, bool post)
{
    resetState();

    if (post) setoptString(CURLOPT_ENCODING, "");

//	setopt(CURLOPT_VERBOSE, 1); // usefull for debugging
    setopt(CURLOPT_NOSIGNAL, 1);

    mOutput.reset(new LLBufferArray);
    setopt(CURLOPT_WRITEFUNCTION, (void*)&curlWriteCallback);
    setopt(CURLOPT_WRITEDATA, (void*)this);

    setopt(CURLOPT_READFUNCTION, (void*)&curlReadCallback);
    setopt(CURLOPT_READDATA, (void*)this);

    setopt(CURLOPT_HEADERFUNCTION, (void*)&curlHeaderCallback);
    setopt(CURLOPT_HEADERDATA, (void*)this);

    setErrorBuffer();
    setCA();

    setopt(CURLOPT_SSL_VERIFYPEER, LLCurl::getSSLVerify());
    setopt(CURLOPT_SSL_VERIFYHOST, LLCurl::getSSLVerify()? 2 : 0);
    setopt(CURLOPT_TIMEOUT, CURL_REQUEST_TIMEOUT);

    setoptString(CURLOPT_URL, url);

    mResponder = responder;

    if (!post)
    {
        slist_append("Connection: keep-alive");
        slist_append("Keep-alive: 300");
        // Accept and other headers
        for (std::vector<std::string>::const_iterator iter = headers.begin();
                iter != headers.end(); ++iter)
        {
            slist_append((*iter).c_str());
        }
    }
}
Beispiel #5
0
void LLCurl::Easy::prepRequest(const std::string& url, ResponderPtr responder, bool post)
{
	resetState();
	
	if (post) setoptString(CURLOPT_ENCODING, "");

//	setopt(CURLOPT_VERBOSE, 1); // usefull for debugging
	setopt(CURLOPT_NOSIGNAL, 1);

	mOutput.reset(new LLBufferArray);
	setopt(CURLOPT_WRITEFUNCTION, (void*)&curlWriteCallback);
	setopt(CURLOPT_WRITEDATA, (void*)this);

	setopt(CURLOPT_READFUNCTION, (void*)&curlReadCallback);
	setopt(CURLOPT_READDATA, (void*)this);
	
	setopt(CURLOPT_HEADERFUNCTION, (void*)&curlHeaderCallback);
	setopt(CURLOPT_HEADERDATA, (void*)this);

	setErrorBuffer();
	setCA();

	setopt(CURLOPT_SSL_VERIFYPEER, true);
	setopt(CURLOPT_TIMEOUT, CURL_REQUEST_TIMEOUT);

	setoptString(CURLOPT_URL, url);

	mResponder = responder;

	if (!post)
	{
		slist_append("Connection: keep-alive");
		slist_append("Keep-alive: 300");
	}
	// *FIX: should have ACCEPT headers
}
Beispiel #6
0
void LLCurl::Easy::prepRequest(const std::string& url,
							   const std::vector<std::string>& headers,
							   ResponderPtr responder, S32 time_out, bool post)
{
	resetState();
	
	if (post) setoptString(CURLOPT_ENCODING, "");

	//setopt(CURLOPT_VERBOSE, 1); // useful for debugging
	setopt(CURLOPT_NOSIGNAL, 1);

	if (LLSocks::getInstance()->isHttpProxyEnabled())
	{
		std::string address = LLSocks::getInstance()->getHTTPProxy().getIPString();
		U16 port = LLSocks::getInstance()->getHTTPProxy().getPort();
		setoptString(CURLOPT_PROXY, address.c_str());
		setopt(CURLOPT_PROXYPORT, port);
		if (LLSocks::getInstance()->getHttpProxyType() == LLPROXY_SOCKS)
		{
			setopt(CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
			if(LLSocks::getInstance()->getSelectedAuthMethod()==METHOD_PASSWORD)
				setoptString(CURLOPT_PROXYUSERPWD,LLSocks::getInstance()->getProxyUserPwd());
		}
		else
		{
			setopt(CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
		}
	}

	mOutput.reset(new LLBufferArray);
	setopt(CURLOPT_WRITEFUNCTION, (void*)&curlWriteCallback);
	setopt(CURLOPT_WRITEDATA, (void*)this);

	setopt(CURLOPT_READFUNCTION, (void*)&curlReadCallback);
	setopt(CURLOPT_READDATA, (void*)this);
	
	setopt(CURLOPT_HEADERFUNCTION, (void*)&curlHeaderCallback);
	setopt(CURLOPT_HEADERDATA, (void*)this);
	// Allow up to five redirects
	if(responder && responder->followRedir())
	{
		setopt(CURLOPT_FOLLOWLOCATION, 1);
		setopt(CURLOPT_MAXREDIRS, MAX_REDIRECTS);
	}

	setErrorBuffer();
	setCA();

	setopt(CURLOPT_SSL_VERIFYPEER, true);
	
	//don't verify host name so urls with scrubbed host names will work (improves DNS performance)
	setopt(CURLOPT_SSL_VERIFYHOST, 0);
	setopt(CURLOPT_TIMEOUT, llmax(time_out, CURL_REQUEST_TIMEOUT));

	setoptString(CURLOPT_URL, url);

	mResponder = responder;

	if (!post)
	{
		slist_append("Connection: keep-alive");
		slist_append("Keep-alive: 300");
		// Accept and other headers
		for (std::vector<std::string>::const_iterator iter = headers.begin();
			 iter != headers.end(); ++iter)
		{
			slist_append((*iter).c_str());
		}
	}
}