lib503.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 TEST_HANG_TIMEOUT 60 * 1000
  29. /*
  30. * Source code in here hugely as reported in bug report 651460 by
  31. * Christopher R. Palmer.
  32. *
  33. * Use multi interface to get HTTPS document over proxy, and provide
  34. * auth info.
  35. */
  36. int test(char *URL)
  37. {
  38. CURL *c = NULL;
  39. CURLM *m = NULL;
  40. int res = 0;
  41. int running;
  42. start_test_timing();
  43. global_init(CURL_GLOBAL_ALL);
  44. easy_init(c);
  45. easy_setopt(c, CURLOPT_PROXY, libtest_arg2); /* set in first.c */
  46. easy_setopt(c, CURLOPT_URL, URL);
  47. easy_setopt(c, CURLOPT_USERPWD, "test:ing");
  48. easy_setopt(c, CURLOPT_PROXYUSERPWD, "test:ing");
  49. easy_setopt(c, CURLOPT_HTTPPROXYTUNNEL, 1L);
  50. easy_setopt(c, CURLOPT_HEADER, 1L);
  51. easy_setopt(c, CURLOPT_VERBOSE, 1L);
  52. multi_init(m);
  53. multi_add_handle(m, c);
  54. for(;;) {
  55. struct timeval interval;
  56. fd_set rd, wr, exc;
  57. int maxfd = -99;
  58. interval.tv_sec = 1;
  59. interval.tv_usec = 0;
  60. multi_perform(m, &running);
  61. abort_on_test_timeout();
  62. if(!running)
  63. break; /* done */
  64. FD_ZERO(&rd);
  65. FD_ZERO(&wr);
  66. FD_ZERO(&exc);
  67. multi_fdset(m, &rd, &wr, &exc, &maxfd);
  68. /* At this point, maxfd is guaranteed to be greater or equal than -1. */
  69. select_test(maxfd + 1, &rd, &wr, &exc, &interval);
  70. abort_on_test_timeout();
  71. }
  72. test_cleanup:
  73. /* proper cleanup sequence - type PA */
  74. curl_multi_remove_handle(m, c);
  75. curl_multi_cleanup(m);
  76. curl_easy_cleanup(c);
  77. curl_global_cleanup();
  78. return res;
  79. }