2
0

lib599.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /***************************************************************************
  2. * _ _ ____ _
  3. * Project ___| | | | _ \| |
  4. * / __| | | | |_) | |
  5. * | (__| |_| | _ <| |___
  6. * \___|\___/|_| \_\_____|
  7. *
  8. * Copyright (C) 1998 - 2012, 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 http://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 "memdebug.h"
  24. static int progress_callback(void *clientp, double dltotal,
  25. double dlnow, double ultotal, double ulnow)
  26. {
  27. (void)clientp;
  28. (void)ulnow;
  29. (void)ultotal;
  30. if((dltotal > 0.0) && (dlnow > dltotal)) {
  31. /* this should not happen with test case 599 */
  32. printf("%.0f > %.0f !!\n", dltotal, dlnow);
  33. return -1;
  34. }
  35. return 0;
  36. }
  37. int test(char *URL)
  38. {
  39. CURL *curl;
  40. CURLcode res=CURLE_OK;
  41. if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
  42. fprintf(stderr, "curl_global_init() failed\n");
  43. return TEST_ERR_MAJOR_BAD;
  44. }
  45. if ((curl = curl_easy_init()) == NULL) {
  46. fprintf(stderr, "curl_easy_init() failed\n");
  47. curl_global_cleanup();
  48. return TEST_ERR_MAJOR_BAD;
  49. }
  50. /* First set the URL that is about to receive our POST. */
  51. test_setopt(curl, CURLOPT_URL, URL);
  52. /* we want to use our own progress function */
  53. test_setopt(curl, CURLOPT_NOPROGRESS, 0L);
  54. test_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
  55. /* get verbose debug output please */
  56. test_setopt(curl, CURLOPT_VERBOSE, 1L);
  57. /* follow redirects */
  58. test_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
  59. /* include headers in the output */
  60. test_setopt(curl, CURLOPT_HEADER, 1L);
  61. /* Perform the request, res will get the return code */
  62. res = curl_easy_perform(curl);
  63. test_cleanup:
  64. /* always cleanup */
  65. curl_easy_cleanup(curl);
  66. curl_global_cleanup();
  67. return res;
  68. }