* This example shows how to add custom headers to a simple * curl request. */
| 11 | * curl request. |
| 12 | */ |
| 13 | int 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 | } |
nothing calls this directly
no test coverage detected