MCPcopy Create free account
hub / github.com/JosephP91/curlcpp / main

Function main

test/easy_info.cpp:16–51  ·  view source on GitHub ↗

* This example shows how to use the easy interface and obtain * informations about the current session. */

Source from the content-addressed store, hash-verified

14 * informations about the current session.
15 */
16int main(int argc, const char **argv) {
17 // Let's declare a stream
18 ostringstream stream;
19
20 // We are going to put the request's output in the previously declared stream
21 curl_ios<ostringstream> ios(stream);
22
23 // Declaration of an easy object
24 curl_easy easy(ios);
25
26 // Add some option to the curl_easy object.
27 easy.add<CURLOPT_URL>("http://www.google.it");
28 easy.add<CURLOPT_FOLLOWLOCATION>(1L);
29
30 try {
31 easy.perform();
32
33 // Retrieve information about curl current session.
34 auto x = easy.get_info<CURLINFO_CONTENT_TYPE>();
35
36 /**
37 * get_info returns a curl_easy_info object. With the get method we retrieve
38 * the std::pair object associated with it: the first item is the return code of the
39 * request. The second is the element requested by the specified libcurl macro.
40 */
41 std::cout<<x.get()<<std::endl;
42
43 } catch (curl_easy_exception &error) {
44 // If you want to print the last error.
45 std::cerr<<error.what()<<std::endl;
46
47 // If you want to print the entire error stack you can do
48 error.print_traceback();
49 }
50 return 0;
51}

Callers

nothing calls this directly

Calls 3

print_tracebackMethod · 0.80
performMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected