2
0

lib503.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. CURLcode test(char *URL)
  37. {
  38. CURL *c = NULL;
  39. CURLM *m = NULL;
  40. CURLcode res = CURLE_OK;
  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_PROXYUSERNAME, "test%20");
  49. easy_setopt(c, CURLOPT_PROXYPASSWORD, "ing%41");
  50. easy_setopt(c, CURLOPT_HTTPPROXYTUNNEL, 1L);
  51. easy_setopt(c, CURLOPT_HEADER, 1L);
  52. easy_setopt(c, CURLOPT_VERBOSE, 1L);
  53. multi_init(m);
  54. multi_add_handle(m, c);
  55. for(;;) {
  56. struct timeval interval;
  57. fd_set rd, wr, exc;
  58. int maxfd = -99;
  59. interval.tv_sec = 1;
  60. interval.tv_usec = 0;
  61. multi_perform(m, &running);
  62. abort_on_test_timeout();
  63. if(!running)
  64. break; /* done */
  65. FD_ZERO(&rd);
  66. FD_ZERO(&wr);
  67. FD_ZERO(&exc);
  68. multi_fdset(m, &rd, &wr, &exc, &maxfd);
  69. /* At this point, maxfd is guaranteed to be greater or equal than -1. */
  70. select_test(maxfd + 1, &rd, &wr, &exc, &interval);
  71. abort_on_test_timeout();
  72. }
  73. test_cleanup:
  74. /* proper cleanup sequence - type PA */
  75. curl_multi_remove_handle(m, c);
  76. curl_multi_cleanup(m);
  77. curl_easy_cleanup(c);
  78. curl_global_cleanup();
  79. return res;
  80. }