lib653.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) 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.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. * SPDX-License-Identifier: curl
  22. *
  23. ***************************************************************************/
  24. #include "test.h"
  25. #include "testutil.h"
  26. #include "warnless.h"
  27. #include "memdebug.h"
  28. CURLcode test(char *URL)
  29. {
  30. CURL *curls = NULL;
  31. CURLcode res = CURLE_OK;
  32. curl_mimepart *field = NULL;
  33. curl_mime *mime = NULL;
  34. global_init(CURL_GLOBAL_ALL);
  35. easy_init(curls);
  36. mime = curl_mime_init(curls);
  37. field = curl_mime_addpart(mime);
  38. curl_mime_name(field, "name");
  39. curl_mime_data(field, "short value", CURL_ZERO_TERMINATED);
  40. easy_setopt(curls, CURLOPT_URL, URL);
  41. easy_setopt(curls, CURLOPT_HEADER, 1L);
  42. easy_setopt(curls, CURLOPT_VERBOSE, 1L);
  43. easy_setopt(curls, CURLOPT_MIMEPOST, mime);
  44. easy_setopt(curls, CURLOPT_NOPROGRESS, 1L);
  45. res = curl_easy_perform(curls);
  46. if(res)
  47. goto test_cleanup;
  48. /* Alter form and resubmit. */
  49. curl_mime_data(field, "long value for length change", CURL_ZERO_TERMINATED);
  50. res = curl_easy_perform(curls);
  51. test_cleanup:
  52. curl_mime_free(mime);
  53. curl_easy_cleanup(curls);
  54. curl_global_cleanup();
  55. return res; /* return the final return code */
  56. }