| 1 | /*************************************************************************** | 
|---|
| 2 | *                                  _   _ ____  _ | 
|---|
| 3 | *  Project                     ___| | | |  _ \| | | 
|---|
| 4 | *                             / __| | | | |_) | | | 
|---|
| 5 | *                            | (__| |_| |  _ <| |___ | 
|---|
| 6 | *                             \___|\___/|_| \_\_____| | 
|---|
| 7 | * | 
|---|
| 8 | * Copyright (C) 1998 - 2019, 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 |  | 
|---|
| 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 | memset(longurl, 'a', EXCESSIVE); | 
|---|
| 38 | longurl[EXCESSIVE-1] = 0; | 
|---|
| 39 |  | 
|---|
| 40 | global_init(CURL_GLOBAL_ALL); | 
|---|
| 41 | easy_init(curl); | 
|---|
| 42 |  | 
|---|
| 43 | res = curl_easy_setopt(curl, CURLOPT_URL, longurl); | 
|---|
| 44 | printf( "CURLOPT_URL %d bytes URL == %d\n", | 
|---|
| 45 | EXCESSIVE, (int)res); | 
|---|
| 46 |  | 
|---|
| 47 | res = curl_easy_setopt(curl, CURLOPT_POSTFIELDS, longurl); | 
|---|
| 48 | printf( "CURLOPT_POSTFIELDS %d bytes data == %d\n", | 
|---|
| 49 | EXCESSIVE, (int)res); | 
|---|
| 50 |  | 
|---|
| 51 | u = curl_url(); | 
|---|
| 52 | if(u) { | 
|---|
| 53 | CURLUcode uc = curl_url_set(u, CURLUPART_URL, longurl, 0); | 
|---|
| 54 | printf( "CURLUPART_URL %d bytes URL == %d\n", | 
|---|
| 55 | EXCESSIVE, (int)uc); | 
|---|
| 56 | uc = curl_url_set(u, CURLUPART_SCHEME, longurl, CURLU_NON_SUPPORT_SCHEME); | 
|---|
| 57 | printf( "CURLUPART_SCHEME %d bytes scheme == %d\n", | 
|---|
| 58 | EXCESSIVE, (int)uc); | 
|---|
| 59 | uc = curl_url_set(u, CURLUPART_USER, longurl, 0); | 
|---|
| 60 | printf( "CURLUPART_USER %d bytes user == %d\n", | 
|---|
| 61 | EXCESSIVE, (int)uc); | 
|---|
| 62 | curl_url_cleanup(u); | 
|---|
| 63 | } | 
|---|
| 64 |  | 
|---|
| 65 | free(longurl); | 
|---|
| 66 |  | 
|---|
| 67 | curl_easy_cleanup(curl); | 
|---|
| 68 | curl_global_cleanup(); | 
|---|
| 69 |  | 
|---|
| 70 | return 0; | 
|---|
| 71 |  | 
|---|
| 72 | test_cleanup: | 
|---|
| 73 |  | 
|---|
| 74 | curl_easy_cleanup(curl); | 
|---|
| 75 | curl_global_cleanup(); | 
|---|
| 76 |  | 
|---|
| 77 | return res; /* return the final return code */ | 
|---|
| 78 | } | 
|---|
| 79 |  | 
|---|