lib503.c 2.5 KB

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