lib512.c 2.0 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 "memdebug.h"
  26. /* Test case code based on source in a bug report filed by James Bursa on
  27. 28 Apr 2004 */
  28. CURLcode test(char *URL)
  29. {
  30. CURLcode code;
  31. int rc = 99;
  32. code = curl_global_init(CURL_GLOBAL_ALL);
  33. if(code == CURLE_OK) {
  34. CURL *curl = curl_easy_init();
  35. if(curl) {
  36. CURL *curl2;
  37. curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
  38. curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
  39. curl2 = curl_easy_duphandle(curl);
  40. if(curl2) {
  41. code = curl_easy_setopt(curl2, CURLOPT_URL, URL);
  42. if(code == CURLE_OK) {
  43. code = curl_easy_perform(curl2);
  44. if(code == CURLE_OK)
  45. rc = 0;
  46. else
  47. rc = 1;
  48. }
  49. else
  50. rc = 2;
  51. curl_easy_cleanup(curl2);
  52. }
  53. else
  54. rc = 3;
  55. curl_easy_cleanup(curl);
  56. }
  57. else
  58. rc = 4;
  59. curl_global_cleanup();
  60. }
  61. else
  62. rc = 5;
  63. return (CURLcode)rc;
  64. }