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 #define EXCESSIVE 10*1000*1000
test(char * URL)31 CURLcode test(char *URL)
32 {
33 CURLcode res = CURLE_OK;
34 CURL *curl = NULL;
35 char *longurl = malloc(EXCESSIVE);
36 CURLU *u;
37 (void)URL;
38
39 if(!longurl)
40 return (CURLcode)1;
41
42 memset(longurl, 'a', EXCESSIVE);
43 longurl[EXCESSIVE-1] = 0;
44
45 global_init(CURL_GLOBAL_ALL);
46 easy_init(curl);
47
48 res = curl_easy_setopt(curl, CURLOPT_URL, longurl);
49 printf("CURLOPT_URL %d bytes URL == %d\n",
50 EXCESSIVE, res);
51
52 res = curl_easy_setopt(curl, CURLOPT_POSTFIELDS, longurl);
53 printf("CURLOPT_POSTFIELDS %d bytes data == %d\n",
54 EXCESSIVE, res);
55
56 u = curl_url();
57 if(u) {
58 CURLUcode uc = curl_url_set(u, CURLUPART_URL, longurl, 0);
59 printf("CURLUPART_URL %d bytes URL == %d (%s)\n",
60 EXCESSIVE, (int)uc, curl_url_strerror(uc));
61 uc = curl_url_set(u, CURLUPART_SCHEME, longurl, CURLU_NON_SUPPORT_SCHEME);
62 printf("CURLUPART_SCHEME %d bytes scheme == %d (%s)\n",
63 EXCESSIVE, (int)uc, curl_url_strerror(uc));
64 uc = curl_url_set(u, CURLUPART_USER, longurl, 0);
65 printf("CURLUPART_USER %d bytes user == %d (%s)\n",
66 EXCESSIVE, (int)uc, curl_url_strerror(uc));
67 curl_url_cleanup(u);
68 }
69
70 test_cleanup:
71 free(longurl);
72 curl_easy_cleanup(curl);
73 curl_global_cleanup();
74
75 return res; /* return the final return code */
76 }
77