lib1559.c 2.3 KB

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