lib653.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. *
  10. * This software is licensed as described in the file COPYING, which
  11. * you should have received as part of this distribution. The terms
  12. * are also available at https://curl.haxx.se/docs/copyright.html.
  13. *
  14. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. * copies of the Software, and permit persons to whom the Software is
  16. * furnished to do so, under the terms of the COPYING file.
  17. *
  18. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. * KIND, either express or implied.
  20. *
  21. ***************************************************************************/
  22. #include "test.h"
  23. #include "testutil.h"
  24. #include "warnless.h"
  25. #include "memdebug.h"
  26. int test(char *URL)
  27. {
  28. CURL *curls = NULL;
  29. int res = 0;
  30. curl_mimepart *field = NULL;
  31. curl_mime *mime = NULL;
  32. global_init(CURL_GLOBAL_ALL);
  33. easy_init(curls);
  34. mime = curl_mime_init(curls);
  35. field = curl_mime_addpart(mime);
  36. curl_mime_name(field, "name");
  37. curl_mime_data(field, "short value", CURL_ZERO_TERMINATED);
  38. easy_setopt(curls, CURLOPT_URL, URL);
  39. easy_setopt(curls, CURLOPT_HEADER, 1L);
  40. easy_setopt(curls, CURLOPT_VERBOSE, 1L);
  41. easy_setopt(curls, CURLOPT_MIMEPOST, mime);
  42. easy_setopt(curls, CURLOPT_NOPROGRESS, 1L);
  43. res = curl_easy_perform(curls);
  44. if(res)
  45. goto test_cleanup;
  46. /* Alter form and resubmit. */
  47. curl_mime_data(field, "long value for length change", CURL_ZERO_TERMINATED);
  48. res = curl_easy_perform(curls);
  49. test_cleanup:
  50. curl_mime_free(mime);
  51. curl_easy_cleanup(curls);
  52. curl_global_cleanup();
  53. return (int) res; /* return the final return code */
  54. }