Пример #1
0
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;
}
Пример #2
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;
}
Пример #3
0
bool LLCurlRequest::getByteRange(const std::string& url, S32 offset, S32 length, LLCurl::ResponderPtr responder)
{
	LLCurl::Easy* easy = allocEasy();
	if (!easy)
	{
		return false;
	}
	easy->prepRequest(url, responder);
	easy->setopt(CURLOPT_HTTPGET, 1);
	if (length > 0)
	{
		std::string range = llformat("Range: bytes=%d-%d", offset,offset+length-1);
		easy->slist_append(range.c_str());
	}
	easy->setHeaders();
	bool res = addEasy(easy);
	return res;
}