0

In Qt C++ they use like this:

QtCUrl::Options opt;
QStringList headers;
headers
    << "Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
    << "Accept-Encoding gzip, deflate"
    << "Accept-Language ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3"
    << "User-Agent  Mozilla/5.0 (X11; Linux x86_64; rv:20.0) Gecko/20100101 Firefox/20.0"
opt[CURLOPT_HTTPHEADER] = headers;

But, i cant use Qt libraries, so how do i do that same declaration of headers in C++11?

1 Answers1

0

First choice:

using namespace std; 
list<string> headers;
    headers.push_back("Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
    headers.push_back("Accept-Encoding gzip, deflate");
    headers.push_back("Accept-Language ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3");
    headers.push_back("User-Agent  Mozilla/5.0 (X11; Linux x86_64; rv:20.0) Gecko/20100101 Firefox/20.0");

Second choice:

using namespace std; 
vector<string> headers;
    headers.push_back("Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
    headers.push_back("Accept-Encoding gzip, deflate");
    headers.push_back("Accept-Language ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3");
    headers.push_back("User-Agent  Mozilla/5.0 (X11; Linux x86_64; rv:20.0) Gecko/20100101 Firefox/20.0");
aldo85ita
  • 496
  • 2
  • 8
  • 19