lib1559.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. if(!longurl)
  35. return 1;
  36. memset(longurl, 'a', EXCESSIVE);
  37. longurl[EXCESSIVE-1] = 0;
  38. global_init(CURL_GLOBAL_ALL);
  39. easy_init(curl);
  40. res = curl_easy_setopt(curl, CURLOPT_URL, longurl);
  41. printf("CURLOPT_URL %d bytes URL == %d\n",
  42. EXCESSIVE, (int)res);
  43. res = curl_easy_setopt(curl, CURLOPT_POSTFIELDS, longurl);
  44. printf("CURLOPT_POSTFIELDS %d bytes data == %d\n",
  45. EXCESSIVE, (int)res);
  46. u = curl_url();
  47. if(u) {
  48. CURLUcode uc = curl_url_set(u, CURLUPART_URL, longurl, 0);
  49. printf("CURLUPART_URL %d bytes URL == %d\n",
  50. EXCESSIVE, (int)uc);
  51. uc = curl_url_set(u, CURLUPART_SCHEME, longurl, CURLU_NON_SUPPORT_SCHEME);
  52. printf("CURLUPART_SCHEME %d bytes scheme == %d\n",
  53. EXCESSIVE, (int)uc);
  54. uc = curl_url_set(u, CURLUPART_USER, longurl, 0);
  55. printf("CURLUPART_USER %d bytes user == %d\n",
  56. EXCESSIVE, (int)uc);
  57. curl_url_cleanup(u);
  58. }
  59. test_cleanup:
  60. free(longurl);
  61. curl_easy_cleanup(curl);
  62. curl_global_cleanup();
  63. return res; /* return the final return code */
  64. }