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