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 26#include "testutil.h" 27#include "warnless.h" 28#include "memdebug.h" 29 30 31int test(char *URL) 32{ 33 CURL *curls = NULL; 34 int res = 0; 35 curl_mimepart *field = NULL; 36 curl_mime *mime = NULL; 37 38 global_init(CURL_GLOBAL_ALL); 39 easy_init(curls); 40 41 mime = curl_mime_init(curls); 42 field = curl_mime_addpart(mime); 43 curl_mime_name(field, "name"); 44 curl_mime_data(field, "short value", CURL_ZERO_TERMINATED); 45 46 easy_setopt(curls, CURLOPT_URL, URL); 47 easy_setopt(curls, CURLOPT_HEADER, 1L); 48 easy_setopt(curls, CURLOPT_VERBOSE, 1L); 49 easy_setopt(curls, CURLOPT_MIMEPOST, mime); 50 easy_setopt(curls, CURLOPT_NOPROGRESS, 1L); 51 52 res = curl_easy_perform(curls); 53 if(res) 54 goto test_cleanup; 55 56 /* Alter form and resubmit. */ 57 curl_mime_data(field, "long value for length change", CURL_ZERO_TERMINATED); 58 res = curl_easy_perform(curls); 59 60test_cleanup: 61 curl_mime_free(mime); 62 curl_easy_cleanup(curls); 63 curl_global_cleanup(); 64 return (int) res; /* return the final return code */ 65} 66