コード例 #1
0
bool LLCurlRequest::post(const std::string& url,
                         const headers_t& headers,
                         const LLSD& data,
                         LLCurl::ResponderPtr responder)
{
    LLCurl::Easy* easy = allocEasy();
    if (!easy)
    {
        return false;
    }
    easy->prepRequest(url, headers, responder);

    LLSDSerialize::toXML(data, easy->getInput());
    S32 bytes = easy->getInput().str().length();

    easy->setopt(CURLOPT_POST, 1);
    easy->setopt(CURLOPT_POSTFIELDS, (void*)NULL);
    easy->setopt(CURLOPT_POSTFIELDSIZE, bytes);

    easy->slist_append("Content-Type: application/llsd+xml");
    easy->setHeaders();

    lldebugs << "POSTING: " << bytes << " bytes." << llendl;
    bool res = addEasy(easy);
    return res;
}
コード例 #2
0
ファイル: llcurl.cpp プロジェクト: HizWylder/GIS
bool LLCurlRequest::post(const std::string& url,
						 const headers_t& headers,
						 const std::string& data,
						 LLCurl::ResponderPtr responder, S32 time_out)
{
	LLCurl::Easy* easy = allocEasy();
	if (!easy)
	{
		return false;
	}
	easy->prepRequest(url, headers, responder, time_out);

	easy->getInput().write(data.data(), data.size());
	S32 bytes = easy->getInput().str().length();
	
	easy->setopt(CURLOPT_POST, 1);
	easy->setopt(CURLOPT_POSTFIELDS, (void*)NULL);
	easy->setopt(CURLOPT_POSTFIELDSIZE, bytes);

	easy->slist_append("Content-Type: application/octet-stream");
	easy->setHeaders();

	lldebugs << "POSTING: " << bytes << " bytes." << llendl;
	bool res = addEasy(easy);
	return res;
}
コード例 #3
0
size_t curlReadCallback(char* data, size_t size, size_t nmemb, void* user_data)
{
    LLCurl::Easy* easy = (LLCurl::Easy*)user_data;

    S32 n = size * nmemb;
    S32 startpos = easy->getInput().tellg();
    easy->getInput().seekg(0, std::ios::end);
    S32 endpos = easy->getInput().tellg();
    easy->getInput().seekg(startpos, std::ios::beg);
    S32 maxn = endpos - startpos;
    n = llmin(n, maxn);
    easy->getInput().read((char*)data, n);

    return n;
}