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 static char teststring[] =
00027 #ifdef CURL_DOES_CONVERSIONS
00028
00029 "\x54\x68\x69\x73\x00\x20\x69\x73\x20\x74\x65\x73\x74\x20\x62\x69\x6e\x61"
00030 "\x72\x79\x20\x64\x61\x74\x61\x20\x77\x69\x74\x68\x20\x61\x6e\x20\x65\x6d"
00031 "\x62\x65\x64\x64\x65\x64\x20\x4e\x55\x4c\x20\x62\x79\x74\x65\x0a";
00032 #else
00033 { 'T', 'h', 'i', 's', '\0', ' ', 'i', 's', ' ', 't', 'e', 's', 't', ' ',
00034 'b', 'i', 'n', 'a', 'r', 'y', ' ', 'd', 'a', 't', 'a', ' ',
00035 'w', 'i', 't', 'h', ' ', 'a', 'n', ' ',
00036 'e', 'm', 'b', 'e', 'd', 'd', 'e', 'd', ' ', 'N', 'U', 'L'};
00037 #endif
00038
00039
00040 int test(char *URL)
00041 {
00042 CURL *curl;
00043 CURLcode res=CURLE_OK;
00044
00045 if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
00046 fprintf(stderr, "curl_global_init() failed\n");
00047 return TEST_ERR_MAJOR_BAD;
00048 }
00049
00050 curl = curl_easy_init();
00051 if(!curl) {
00052 fprintf(stderr, "curl_easy_init() failed\n");
00053 curl_global_cleanup();
00054 return TEST_ERR_MAJOR_BAD;
00055 }
00056
00057
00058 test_setopt(curl, CURLOPT_URL, URL);
00059
00060 #ifdef LIB545
00061 test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof teststring);
00062 #endif
00063
00064 test_setopt(curl, CURLOPT_COPYPOSTFIELDS, teststring);
00065
00066 test_setopt(curl, CURLOPT_VERBOSE, 1L);
00067 test_setopt(curl, CURLOPT_HEADER, 1L);
00068
00069
00070 strcpy(teststring, "FAIL");
00071
00072 #ifdef LIB545
00073 {
00074 CURL *handle2;
00075 handle2 = curl_easy_duphandle(curl);
00076 curl_easy_cleanup(curl);
00077
00078 curl = handle2;
00079 }
00080 #endif
00081
00082
00083 res = curl_easy_perform(curl);
00084
00085 test_cleanup:
00086
00087
00088 curl_easy_cleanup(curl);
00089 curl_global_cleanup();
00090
00091 return (int)res;
00092 }