quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

lib1559.c (2546B)


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