lib1559.c 2.4 KB

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