httpcustomheader.c 982 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*****************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * $Id$
  9. */
  10. #include <stdio.h>
  11. #include <curl/curl.h>
  12. int main(void)
  13. {
  14. CURL *curl;
  15. CURLcode res;
  16. curl = curl_easy_init();
  17. if(curl) {
  18. struct curl_slist *chunk = NULL;
  19. chunk = curl_slist_append(chunk, "Accept: moo");
  20. /* request with the built-in Accept: */
  21. curl_easy_setopt(curl, CURLOPT_URL, "localhost");
  22. curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
  23. res = curl_easy_perform(curl);
  24. /* redo request with our own custom Accept: */
  25. res = curl_easy_setopt(curl, CURLOPT_HTTPHEADER, chunk);
  26. res = curl_easy_perform(curl);
  27. /* always cleanup */
  28. curl_easy_cleanup(curl);
  29. }
  30. return 0;
  31. }