113498266Sopenharmony_ci<testcase>
213498266Sopenharmony_ci<info>
313498266Sopenharmony_ci<keywords>
413498266Sopenharmony_ciHTTP
513498266Sopenharmony_ciHTTP POST
613498266Sopenharmony_ci--libcurl
713498266Sopenharmony_ci</keywords>
813498266Sopenharmony_ci</info>
913498266Sopenharmony_ci
1013498266Sopenharmony_ci# Server-side
1113498266Sopenharmony_ci<reply>
1213498266Sopenharmony_ci<data>
1313498266Sopenharmony_ciHTTP/1.1 200 OK
1413498266Sopenharmony_ciDate: Thu, 29 Jul 2008 14:49:00 GMT
1513498266Sopenharmony_ciServer: test-server/fake
1613498266Sopenharmony_ciContent-Length: 0
1713498266Sopenharmony_ciContent-Type: text/plain
1813498266Sopenharmony_ciConnection: close
1913498266Sopenharmony_ci
2013498266Sopenharmony_ci</data>
2113498266Sopenharmony_ci</reply>
2213498266Sopenharmony_ci
2313498266Sopenharmony_ci# Client-side
2413498266Sopenharmony_ci<client>
2513498266Sopenharmony_ci<server>
2613498266Sopenharmony_cihttp
2713498266Sopenharmony_ci</server>
2813498266Sopenharmony_ci<name>
2913498266Sopenharmony_ci--libcurl for POST with binary content
3013498266Sopenharmony_ci</name>
3113498266Sopenharmony_ci<setenv>
3213498266Sopenharmony_ciSSL_CERT_FILE=
3313498266Sopenharmony_ci</setenv>
3413498266Sopenharmony_ci<command>
3513498266Sopenharmony_cihttp://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER --libcurl %LOGDIR/test%TESTNUMBER.c --data-binary @%LOGDIR/%TESTNUMBER-upload
3613498266Sopenharmony_ci</command>
3713498266Sopenharmony_ci# "ab\x81""cd\0e\\\"?\r\n\t\x01""fghi%x1Ajklm%xFD"
3813498266Sopenharmony_ci<file name="%LOGDIR/%TESTNUMBER-upload" nonewline="yes">
3913498266Sopenharmony_ci%hex[ab%81cd%00e\"?%0D%0A%09%01fghi%1Ajklm%FD]hex%
4013498266Sopenharmony_ci</file>
4113498266Sopenharmony_ci</client>
4213498266Sopenharmony_ci
4313498266Sopenharmony_ci# Verify data after the test has been "shot"
4413498266Sopenharmony_ci<verify>
4513498266Sopenharmony_ci<protocol nonewline="yes">
4613498266Sopenharmony_ciPOST /we/want/%TESTNUMBER HTTP/1.1
4713498266Sopenharmony_ciHost: %HOSTIP:%HTTPPORT
4813498266Sopenharmony_ciUser-Agent: curl/%VERSION
4913498266Sopenharmony_ciAccept: */*
5013498266Sopenharmony_ciContent-Length: 24
5113498266Sopenharmony_ciContent-Type: application/x-www-form-urlencoded
5213498266Sopenharmony_ci
5313498266Sopenharmony_ci%hex[ab%81cd%00e\"?%0D%0A%09%01fghi%1Ajklm%FD]hex%
5413498266Sopenharmony_ci</protocol>
5513498266Sopenharmony_ci<stripfile>
5613498266Sopenharmony_ci
5713498266Sopenharmony_ci# CURLOPT_SSL_VERIFYPEER, SSH_KNOWNHOSTS and HTTP_VERSION vary with
5813498266Sopenharmony_ci# configurations - just ignore them
5913498266Sopenharmony_ci$_ = '' if /CURLOPT_SSL_VERIFYPEER/
6013498266Sopenharmony_ci$_ = '' if /CURLOPT_SSH_KNOWNHOSTS/
6113498266Sopenharmony_ci$_ = '' if /CURLOPT_HTTP_VERSION/
6213498266Sopenharmony_ci$_ = '' if /CURLOPT_INTERLEAVEDATA/
6313498266Sopenharmony_ci</stripfile>
6413498266Sopenharmony_ci<file name="%LOGDIR/test%TESTNUMBER.c" mode="text">
6513498266Sopenharmony_ci/********* Sample code generated by the curl command line tool **********
6613498266Sopenharmony_ci * All curl_easy_setopt() options are documented at:
6713498266Sopenharmony_ci * https://curl.se/libcurl/c/curl_easy_setopt.html
6813498266Sopenharmony_ci ************************************************************************/
6913498266Sopenharmony_ci#include <curl/curl.h>
7013498266Sopenharmony_ci
7113498266Sopenharmony_ciint main(int argc, char *argv[])
7213498266Sopenharmony_ci{
7313498266Sopenharmony_ci  CURLcode ret;
7413498266Sopenharmony_ci  CURL *hnd;
7513498266Sopenharmony_ci
7613498266Sopenharmony_ci  hnd = curl_easy_init();
7713498266Sopenharmony_ci  curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
7813498266Sopenharmony_ci  curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER");
7913498266Sopenharmony_ci  curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "ab\201cd\000e\\\"\?\r\n\t\001fghi\x1ajklm\xfd");
8013498266Sopenharmony_ci  curl_easy_setopt(hnd, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)24);
8113498266Sopenharmony_ci  curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/%VERSION");
8213498266Sopenharmony_ci  curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
8313498266Sopenharmony_ci  curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
8413498266Sopenharmony_ci%if ftp
8513498266Sopenharmony_ci  curl_easy_setopt(hnd, CURLOPT_FTP_SKIP_PASV_IP, 1L);
8613498266Sopenharmony_ci%endif
8713498266Sopenharmony_ci  curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);
8813498266Sopenharmony_ci
8913498266Sopenharmony_ci  /* Here is a list of options the curl code used that cannot get generated
9013498266Sopenharmony_ci     as source easily. You may choose to either not use them or implement
9113498266Sopenharmony_ci     them yourself.
9213498266Sopenharmony_ci
9313498266Sopenharmony_ci  CURLOPT_WRITEDATA was set to an object pointer
9413498266Sopenharmony_ci  CURLOPT_WRITEFUNCTION was set to a function pointer
9513498266Sopenharmony_ci  CURLOPT_READDATA was set to an object pointer
9613498266Sopenharmony_ci  CURLOPT_READFUNCTION was set to a function pointer
9713498266Sopenharmony_ci  CURLOPT_SEEKDATA was set to an object pointer
9813498266Sopenharmony_ci  CURLOPT_SEEKFUNCTION was set to a function pointer
9913498266Sopenharmony_ci  CURLOPT_ERRORBUFFER was set to an object pointer
10013498266Sopenharmony_ci  CURLOPT_STDERR was set to an object pointer
10113498266Sopenharmony_ci  CURLOPT_DEBUGFUNCTION was set to a function pointer
10213498266Sopenharmony_ci  CURLOPT_DEBUGDATA was set to an object pointer
10313498266Sopenharmony_ci  CURLOPT_HEADERFUNCTION was set to a function pointer
10413498266Sopenharmony_ci  CURLOPT_HEADERDATA was set to an object pointer
10513498266Sopenharmony_ci
10613498266Sopenharmony_ci  */
10713498266Sopenharmony_ci
10813498266Sopenharmony_ci  ret = curl_easy_perform(hnd);
10913498266Sopenharmony_ci
11013498266Sopenharmony_ci  curl_easy_cleanup(hnd);
11113498266Sopenharmony_ci  hnd = NULL;
11213498266Sopenharmony_ci
11313498266Sopenharmony_ci  return (int)ret;
11413498266Sopenharmony_ci}
11513498266Sopenharmony_ci/**** End of sample code ****/
11613498266Sopenharmony_ci</file>
11713498266Sopenharmony_ci</verify>
11813498266Sopenharmony_ci</testcase>
119