mirror of
https://gitlab.com/niansa/qcommsy.git
synced 2025-03-06 20:53:33 +01:00
28 lines
1 KiB
C++
28 lines
1 KiB
C++
#include <sstream>
|
|
|
|
#include <curlpp/cURLpp.hpp>
|
|
#include <curlpp/Easy.hpp>
|
|
#include <curlpp/Infos.hpp>
|
|
#include <curlpp/Options.hpp>
|
|
|
|
long curlreq(std::stringstream &responsebuffer, std::string SID, std::string URL) {
|
|
std::cout << "Connection details begin" << std::endl;
|
|
std::cout << "URL: " << URL << std::endl;
|
|
std::cout << "SID: " << SID << std::endl;
|
|
std::cout << "Connection details end" << std::endl;
|
|
// Initialise variables
|
|
curlpp::Cleanup cleaner;
|
|
curlpp::Easy request;
|
|
// Set the writer callback to enable cURL to write result in a memory area
|
|
request.setOpt(new curlpp::options::WriteStream(&responsebuffer));
|
|
// Setting the URL to retrive.
|
|
request.setOpt(new curlpp::options::Url(URL));
|
|
// Set SID cookie
|
|
std::list<std::string> header;
|
|
header.push_back("Cookie: SID=" + SID);
|
|
request.setOpt(new curlpp::options::HttpHeader(header));
|
|
// Perform request
|
|
request.perform();
|
|
// Return result
|
|
return curlpp::infos::ResponseCode::get(request);
|
|
}
|