getinfo.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. /* http://curl.haxx.se/libcurl/c/curl_easy_init.html */
  17. curl = curl_easy_init();
  18. if(curl) {
  19. /* http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTURL */
  20. curl_easy_setopt(curl, CURLOPT_URL, "curl.haxx.se");
  21. /* http://curl.haxx.se/libcurl/c/curl_easy_perform.html */
  22. res = curl_easy_perform(curl);
  23. if(CURLE_OK == res) {
  24. char *ct;
  25. /* ask for the content-type */
  26. /* http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html */
  27. res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
  28. if((CURLE_OK == res) && ct)
  29. printf("We received Content-Type: %s\n", ct);
  30. }
  31. /* always cleanup */
  32. /* http://curl.haxx.se/libcurl/c/curl_easy_cleanup.html */
  33. curl_easy_cleanup(curl);
  34. }
  35. return 0;
  36. }