xref: /curl/tests/data/test1402 (revision 3fd80c7b)
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 simple POST
30</name>
31<setenv>
32SSL_CERT_FILE=
33</setenv>
34<command>
35http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER --libcurl %LOGDIR/test%TESTNUMBER.c -d "foo=bar" -d "baz=quux"
36</command>
37</client>
38
39# Verify data after the test has been "shot"
40<verify>
41<protocol nonewline="yes">
42POST /we/want/%TESTNUMBER HTTP/1.1
43Host: %HOSTIP:%HTTPPORT
44User-Agent: curl/%VERSION
45Accept: */*
46Content-Length: 16
47Content-Type: application/x-www-form-urlencoded
48
49foo=bar&baz=quux
50</protocol>
51<stripfile>
52# curl's default user-agent varies with version, libraries etc.
53s/(USERAGENT, \")[^\"]+/${1}stripped/
54# CURLOPT_SSL_VERIFYPEER, SSH_KNOWNHOSTS and HTTP_VERSION vary with
55# configurations - just ignore them
56$_ = '' if /CURLOPT_SSL_VERIFYPEER/
57$_ = '' if /CURLOPT_SSH_KNOWNHOSTS/
58$_ = '' if /CURLOPT_HTTP_VERSION/
59$_ = '' if /CURLOPT_INTERLEAVEDATA/
60</stripfile>
61<file name="%LOGDIR/test%TESTNUMBER.c" mode="text">
62/********* Sample code generated by the curl command line tool **********
63 * All curl_easy_setopt() options are documented at:
64 * https://curl.se/libcurl/c/curl_easy_setopt.html
65 ************************************************************************/
66#include <curl/curl.h>
67
68int main(int argc, char *argv[])
69{
70  CURLcode ret;
71  CURL *hnd;
72
73  hnd = curl_easy_init();
74  curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
75  curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER");
76  curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "foo=bar&baz=quux");
77  curl_easy_setopt(hnd, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)16);
78  curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped");
79  curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
80  curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
81%if ftp
82  curl_easy_setopt(hnd, CURLOPT_FTP_SKIP_PASV_IP, 1L);
83%endif
84  curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);
85
86  /* Here is a list of options the curl code used that cannot get generated
87     as source easily. You may choose to either not use them or implement
88     them yourself.
89
90  CURLOPT_WRITEDATA was set to an object pointer
91  CURLOPT_WRITEFUNCTION was set to a function pointer
92  CURLOPT_READDATA was set to an object pointer
93  CURLOPT_READFUNCTION was set to a function pointer
94  CURLOPT_SEEKDATA was set to an object pointer
95  CURLOPT_SEEKFUNCTION was set to a function pointer
96  CURLOPT_ERRORBUFFER was set to an object pointer
97  CURLOPT_STDERR was set to an object pointer
98  CURLOPT_DEBUGFUNCTION was set to a function pointer
99  CURLOPT_DEBUGDATA was set to an object pointer
100  CURLOPT_HEADERFUNCTION was set to a function pointer
101  CURLOPT_HEADERDATA was set to an object pointer
102
103  */
104
105  ret = curl_easy_perform(hnd);
106
107  curl_easy_cleanup(hnd);
108  hnd = NULL;
109
110  return (int)ret;
111}
112/**** End of sample code ****/
113</file>
114</verify>
115</testcase>
116