1<testcase> 2<info> 3<keywords> 4HTTP 5HTTP GET 6HTTP Basic auth 7HTTP set cookie 8cookies 9--libcurl 10</keywords> 11</info> 12 13# Server-side 14<reply> 15<data> 16HTTP/1.1 200 OK 17Date: Thu, 29 Jul 2008 14:49:00 GMT 18Server: test-server/fake 19Content-Length: 0 20Content-Type: text/plain 21Connection: close 22 23</data> 24</reply> 25 26# Client-side 27<client> 28<server> 29http 30</server> 31 <name> 32--libcurl for GET with various options 33 </name> 34<features> 35http 36ftp 37file 38</features> 39<setenv> 40SSL_CERT_FILE= 41</setenv> 42 <command> 43http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER --libcurl log/test%TESTNUMBER.c --basic -u fake:user -H "X-Files: Mulder" -H "X-Men: cyclops, iceman" -A MyUA -b chocolate=chip --proto "=http,ftp,file" 44</command> 45</client> 46 47# Verify data after the test has been "shot" 48<verify> 49<protocol> 50GET /we/want/%TESTNUMBER HTTP/1.1 51Host: %HOSTIP:%HTTPPORT 52Authorization: Basic ZmFrZTp1c2Vy 53User-Agent: MyUA 54Accept: */* 55Cookie: chocolate=chip 56X-Files: Mulder 57X-Men: cyclops, iceman 58 59</protocol> 60<stripfile> 61# CURLOPT_SSL_VERIFYPEER, SSH_KNOWNHOSTS and HTTP_VERSION vary with 62# configurations - just ignore them 63$_ = '' if /CURLOPT_SSL_VERIFYPEER/ 64$_ = '' if /CURLOPT_SSH_KNOWNHOSTS/ 65$_ = '' if /CURLOPT_HTTP_VERSION/ 66$_ = '' if /CURLOPT_INTERLEAVEDATA/ 67</stripfile> 68<file name="log/test%TESTNUMBER.c" mode="text"> 69/********* Sample code generated by the curl command line tool ********** 70 * All curl_easy_setopt() options are documented at: 71 * https://curl.se/libcurl/c/curl_easy_setopt.html 72 ************************************************************************/ 73#include <curl/curl.h> 74 75int main(int argc, char *argv[]) 76{ 77 CURLcode ret; 78 CURL *hnd; 79 struct curl_slist *slist1; 80 81 slist1 = NULL; 82 slist1 = curl_slist_append(slist1, "X-Files: Mulder"); 83 slist1 = curl_slist_append(slist1, "X-Men: cyclops, iceman"); 84 85 hnd = curl_easy_init(); 86 curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L); 87 curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER"); 88 curl_easy_setopt(hnd, CURLOPT_USERPWD, "fake:user"); 89 curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC); 90 curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, slist1); 91 curl_easy_setopt(hnd, CURLOPT_USERAGENT, "MyUA"); 92 curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); 93 curl_easy_setopt(hnd, CURLOPT_COOKIE, "chocolate=chip"); 94 curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); 95%if ftp 96 curl_easy_setopt(hnd, CURLOPT_FTP_SKIP_PASV_IP, 1L); 97%endif 98 curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); 99 curl_easy_setopt(hnd, CURLOPT_PROTOCOLS_STR, "file,ftp,http"); 100 101 /* Here is a list of options the curl code used that cannot get generated 102 as source easily. You may choose to either not use them or implement 103 them yourself. 104 105 CURLOPT_WRITEDATA was set to an object pointer 106 CURLOPT_WRITEFUNCTION was set to a function pointer 107 CURLOPT_READDATA was set to an object pointer 108 CURLOPT_READFUNCTION was set to a function pointer 109 CURLOPT_SEEKDATA was set to an object pointer 110 CURLOPT_SEEKFUNCTION was set to a function pointer 111 CURLOPT_ERRORBUFFER was set to an object pointer 112 CURLOPT_STDERR was set to an object pointer 113 CURLOPT_DEBUGFUNCTION was set to a function pointer 114 CURLOPT_DEBUGDATA was set to an object pointer 115 CURLOPT_HEADERFUNCTION was set to a function pointer 116 CURLOPT_HEADERDATA was set to an object pointer 117 118 */ 119 120 ret = curl_easy_perform(hnd); 121 122 curl_easy_cleanup(hnd); 123 hnd = NULL; 124 curl_slist_free_all(slist1); 125 slist1 = NULL; 126 127 return (int)ret; 128} 129/**** End of sample code ****/ 130</file> 131</verify> 132</testcase> 133