00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "test.h"
00023
00024 #include "memdebug.h"
00025
00026
00027
00028 int test(char *URL)
00029 {
00030 CURL *curl, *dupe = NULL;
00031 long filetime;
00032 int res = CURLE_OK;
00033
00034 global_init(CURL_GLOBAL_ALL);
00035
00036 easy_init(curl);
00037
00038
00039
00040
00041 res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
00042 if(res) {
00043 fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
00044 __FILE__, __LINE__, res, curl_easy_strerror(res));
00045 goto test_cleanup;
00046 }
00047 if(filetime != -1) {
00048 fprintf(stderr, "%s:%d filetime init failed; expected -1 but is %ld\n",
00049 __FILE__, __LINE__, filetime);
00050 res = CURLE_FAILED_INIT;
00051 goto test_cleanup;
00052 }
00053
00054 easy_setopt(curl, CURLOPT_URL, URL);
00055 easy_setopt(curl, CURLOPT_FILETIME, 1L);
00056
00057 res = curl_easy_perform(curl);
00058 if(res) {
00059 fprintf(stderr, "%s:%d curl_easy_perform() failed with code %d (%s)\n",
00060 __FILE__, __LINE__, res, curl_easy_strerror(res));
00061 goto test_cleanup;
00062 }
00063
00064
00065
00066
00067 res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
00068 if(res) {
00069 fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
00070 __FILE__, __LINE__, res, curl_easy_strerror(res));
00071 goto test_cleanup;
00072 }
00073 if(filetime != 30) {
00074 fprintf(stderr, "%s:%d filetime of http resource is incorrect; "
00075 "expected 30 but is %ld\n",
00076 __FILE__, __LINE__, filetime);
00077 res = CURLE_HTTP_RETURNED_ERROR;
00078 goto test_cleanup;
00079 }
00080
00081
00082
00083
00084 dupe = curl_easy_duphandle(curl);
00085 if(!dupe) {
00086 fprintf(stderr, "%s:%d curl_easy_duphandle() failed\n",
00087 __FILE__, __LINE__);
00088 res = CURLE_FAILED_INIT;
00089 goto test_cleanup;
00090 }
00091
00092 res = curl_easy_getinfo(dupe, CURLINFO_FILETIME, &filetime);
00093 if(res) {
00094 fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
00095 __FILE__, __LINE__, res, curl_easy_strerror(res));
00096 goto test_cleanup;
00097 }
00098 if(filetime != -1) {
00099 fprintf(stderr, "%s:%d filetime init failed; expected -1 but is %ld\n",
00100 __FILE__, __LINE__, filetime);
00101 res = CURLE_FAILED_INIT;
00102 goto test_cleanup;
00103 }
00104
00105
00106
00107
00108
00109 curl_easy_reset(curl);
00110
00111 res = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
00112 if(res) {
00113 fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
00114 __FILE__, __LINE__, res, curl_easy_strerror(res));
00115 goto test_cleanup;
00116 }
00117 if(filetime != -1) {
00118 fprintf(stderr, "%s:%d filetime init failed; expected -1 but is %ld\n",
00119 __FILE__, __LINE__, filetime);
00120 res = CURLE_FAILED_INIT;
00121 goto test_cleanup;
00122 }
00123
00124 test_cleanup:
00125 curl_easy_cleanup(curl);
00126 curl_easy_cleanup(dupe);
00127 curl_global_cleanup();
00128 return res;
00129 }