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

Function main

test/header.cpp:13–39  ·  view source on GitHub ↗

* This example shows how to add custom headers to a simple * curl request. */

Source from the content-addressed store, hash-verified

11 * curl request.
12 */
13int main() {
14 // Easy object to handle the connection.
15 curl_easy easy;
16
17 // Let's create an object which will contain a list of headers.
18 curl::curl_header header;
19 header.add("Accept:");
20 header.add("Another:yes");
21 header.add("Host: example.com");
22
23 // Add the headers to the easy object.
24 easy.add<CURLOPT_HTTPHEADER>(header.get());
25
26 easy.add<CURLOPT_URL>("http://example.com");
27 easy.add<CURLOPT_VERBOSE>(1L);
28
29 try {
30 easy.perform();
31 } catch (curl_easy_exception &error) {
32 // If you want to print the last error.
33 std::cerr<<error.what()<<std::endl;
34
35 // If you want to print the entire error stack you can do
36 error.print_traceback();
37 }
38 return 0;
39}

Callers

nothing calls this directly

Calls 4

print_tracebackMethod · 0.80
addMethod · 0.45
getMethod · 0.45
performMethod · 0.45

Tested by

no test coverage detected