lib544.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*****************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * $Id$
  9. */
  10. #include "test.h"
  11. static char teststring[] =
  12. "This\0 is test binary data with an embedded NUL byte\n";
  13. int test(char *URL)
  14. {
  15. CURL *curl;
  16. CURLcode res=CURLE_OK;
  17. if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
  18. fprintf(stderr, "curl_global_init() failed\n");
  19. return TEST_ERR_MAJOR_BAD;
  20. }
  21. if ((curl = curl_easy_init()) == NULL) {
  22. fprintf(stderr, "curl_easy_init() failed\n");
  23. curl_global_cleanup();
  24. return TEST_ERR_MAJOR_BAD;
  25. }
  26. /* First set the URL that is about to receive our POST. */
  27. curl_easy_setopt(curl, CURLOPT_URL, URL);
  28. #ifdef LIB545
  29. curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof teststring - 1);
  30. #endif
  31. curl_easy_setopt(curl, CURLOPT_COPYPOSTFIELDS, teststring);
  32. curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
  33. curl_easy_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
  34. /* Update the original data to detect non-copy. */
  35. strcpy(teststring, "FAIL");
  36. /* Now, this is a POST request with binary 0 embedded in POST data. */
  37. res = curl_easy_perform(curl);
  38. /* always cleanup */
  39. curl_easy_cleanup(curl);
  40. curl_global_cleanup();
  41. return (int)res;
  42. }