1 <testcase> 2 <info> 3 <keywords> 4 HTTP 5 HTTP POST 6 --libcurl 7 </keywords> 8 </info> 9 10 # Server-side 11 <reply> 12 <data> 13 HTTP/1.1 200 OK 14 Date: Thu, 29 Jul 2008 14:49:00 GMT 15 Server: test-server/fake 16 Content-Length: 0 17 Content-Type: text/plain 18 Connection: close 19 20 </data> 21 </reply> 22 23 # Client-side 24 <client> 25 <server> 26 http 27 </server> 28 <name> 29 --libcurl for simple POST 30 </name> 31 <command> 32 http://%HOSTIP:%HTTPPORT/we/want/1402 --libcurl log/test1402.c -d "foo=bar" -d "baz=quux" 33 </command> 34 </client> 35 36 # Verify data after the test has been "shot" 37 <verify> 38 <strip> 39 ^User-Agent:.* 40 </strip> 41 <protocol nonewline="yes"> 42 POST /we/want/1402 HTTP/1.1 43 User-Agent: curl/7.18.2 (i686-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.7a ipv6 zlib/1.1.4 44 Host: %HOSTIP:%HTTPPORT 45 Accept: */* 46 Content-Length: 16 47 Content-Type: application/x-www-form-urlencoded 48 49 foo=bar&baz=quux 50 </protocol> 51 <stripfile> 52 # curl's default user-agent varies with version, libraries etc. 53 s/(USERAGENT, \")[^\"]+/${1}stripped/ 54 # CURLOPT_SSL_VERIFYPEER and SSH_KNOWNHOSTS vary with configurations - just 55 # ignore them 56 $_ = '' if /CURLOPT_SSL_VERIFYPEER/ 57 $_ = '' if /CURLOPT_SSH_KNOWNHOSTS/ 58 </stripfile> 59 <file name="log/test1402.c" mode="text"> 60 /********* Sample code generated by the curl command line tool ********** 61 * All curl_easy_setopt() options are documented at: 62 * http://curl.haxx.se/libcurl/c/curl_easy_setopt.html 63 ************************************************************************/ 64 #include <curl/curl.h> 65 66 int main(int argc, char *argv[]) 67 { 68 CURLcode ret; 69 CURL *hnd; 70 71 hnd = curl_easy_init(); 72 curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/1402"); 73 curl_easy_setopt(hnd, CURLOPT_HEADER, 1L); 74 curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "foo=bar&baz=quux"); 75 curl_easy_setopt(hnd, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)16); 76 curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped"); 77 curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L); 78 curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L); 79 curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L); 80 81 /* Here is a list of options the curl code used that cannot get generated 82 as source easily. You may select to either not use them or implement 83 them yourself. 84 85 CURLOPT_WRITEDATA set to a objectpointer 86 CURLOPT_WRITEFUNCTION set to a functionpointer 87 CURLOPT_READDATA set to a objectpointer 88 CURLOPT_READFUNCTION set to a functionpointer 89 CURLOPT_SEEKDATA set to a objectpointer 90 CURLOPT_SEEKFUNCTION set to a functionpointer 91 CURLOPT_ERRORBUFFER set to a objectpointer 92 CURLOPT_STDERR set to a objectpointer 93 CURLOPT_DEBUGFUNCTION set to a functionpointer 94 CURLOPT_DEBUGDATA set to a objectpointer 95 CURLOPT_HEADERFUNCTION set to a functionpointer 96 CURLOPT_HEADERDATA set to a objectpointer 97 98 */ 99 100 ret = curl_easy_perform(hnd); 101 102 curl_easy_cleanup(hnd); 103 hnd = NULL; 104 105 return (int)ret; 106 } 107 /**** End of sample code ****/ 108 </file> 109 <stdout> 110 </stdout> 111 </verify> 112 </testcase> 113