1 | /*************************************************************************** |
2 | * _ _ ____ _ |
3 | * Project ___| | | | _ \| | |
4 | * / __| | | | |_) | | |
5 | * | (__| |_| | _ <| |___ |
6 | * \___|\___/|_| \_\_____| |
7 | * |
8 | * Copyright (C) 1998 - 2020, 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 | ***************************************************************************/ |
22 | #include "test.h" |
23 | |
24 | #include "testutil.h" |
25 | #include "warnless.h" |
26 | #include "memdebug.h" |
27 | |
28 | #define EXCESSIVE 10*1000*1000 |
29 | int test(char *URL) |
30 | { |
31 | CURLcode res = 0; |
32 | CURL *curl = NULL; |
33 | char *longurl = malloc(EXCESSIVE); |
34 | CURLU *u; |
35 | (void)URL; |
36 | |
37 | if(!longurl) |
38 | return 1; |
39 | |
40 | memset(longurl, 'a', EXCESSIVE); |
41 | longurl[EXCESSIVE-1] = 0; |
42 | |
43 | global_init(CURL_GLOBAL_ALL); |
44 | easy_init(curl); |
45 | |
46 | res = curl_easy_setopt(curl, CURLOPT_URL, longurl); |
47 | printf("CURLOPT_URL %d bytes URL == %d\n" , |
48 | EXCESSIVE, (int)res); |
49 | |
50 | res = curl_easy_setopt(curl, CURLOPT_POSTFIELDS, longurl); |
51 | printf("CURLOPT_POSTFIELDS %d bytes data == %d\n" , |
52 | EXCESSIVE, (int)res); |
53 | |
54 | u = curl_url(); |
55 | if(u) { |
56 | CURLUcode uc = curl_url_set(u, CURLUPART_URL, longurl, 0); |
57 | printf("CURLUPART_URL %d bytes URL == %d\n" , |
58 | EXCESSIVE, (int)uc); |
59 | uc = curl_url_set(u, CURLUPART_SCHEME, longurl, CURLU_NON_SUPPORT_SCHEME); |
60 | printf("CURLUPART_SCHEME %d bytes scheme == %d\n" , |
61 | EXCESSIVE, (int)uc); |
62 | uc = curl_url_set(u, CURLUPART_USER, longurl, 0); |
63 | printf("CURLUPART_USER %d bytes user == %d\n" , |
64 | EXCESSIVE, (int)uc); |
65 | curl_url_cleanup(u); |
66 | } |
67 | |
68 | test_cleanup: |
69 | free(longurl); |
70 | curl_easy_cleanup(curl); |
71 | curl_global_cleanup(); |
72 | |
73 | return res; /* return the final return code */ |
74 | } |
75 | |