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 char *scheme;
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_SCHEME, &scheme);
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(scheme != NULL) {
00048 fprintf(stderr, "%s:%d scheme init failed; expected NULL\n",
00049 __FILE__, __LINE__);
00050 res = CURLE_FAILED_INIT;
00051 goto test_cleanup;
00052 }
00053
00054 easy_setopt(curl, CURLOPT_URL, URL);
00055
00056 res = curl_easy_perform(curl);
00057 if(res) {
00058 fprintf(stderr, "%s:%d curl_easy_perform() failed with code %d (%s)\n",
00059 __FILE__, __LINE__, res, curl_easy_strerror(res));
00060 goto test_cleanup;
00061 }
00062
00063
00064
00065
00066 res = curl_easy_getinfo(curl, CURLINFO_SCHEME, &scheme);
00067 if(res) {
00068 fprintf(stderr, "%s:%d curl_easy_getinfo() failed with code %d (%s)\n",
00069 __FILE__, __LINE__, res, curl_easy_strerror(res));
00070 goto test_cleanup;
00071 }
00072 if(memcmp(scheme, "HTTP", 5) != 0) {
00073 fprintf(stderr, "%s:%d scheme of http resource is incorrect; "
00074 "expected 'HTTP' but is %s\n",
00075 __FILE__, __LINE__, CURLPROTO_HTTP,
00076 (scheme == NULL ? "NULL" : "invalid"));
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_SCHEME, &scheme);
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(scheme != 0) {
00099 fprintf(stderr, "%s:%d scheme init failed; expected NULL\n",
00100 __FILE__, __LINE__);
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_SCHEME, &scheme);
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(scheme != 0) {
00118 fprintf(stderr, "%s:%d scheme init failed; expected NULL\n",
00119 __FILE__, __LINE__);
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 }