• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/1402 --libcurl log/test1402.c -d "foo=bar" -d "baz=quux"
36</command>
37</client>
38
39# Verify data after the test has been "shot"
40<verify>
41<strip>
42^User-Agent:.*
43</strip>
44<protocol nonewline="yes">
45POST /we/want/1402 HTTP/1.1
46User-Agent: curl/7.18.2 (i686-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.7a ipv6 zlib/1.1.4
47Host: %HOSTIP:%HTTPPORT
48Accept: */*
49Content-Length: 16
50Content-Type: application/x-www-form-urlencoded
51
52foo=bar&baz=quux
53</protocol>
54<stripfile>
55# curl's default user-agent varies with version, libraries etc.
56s/(USERAGENT, \")[^\"]+/${1}stripped/
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</stripfile>
63<file name="log/test1402.c" mode="text">
64/********* Sample code generated by the curl command line tool **********
65 * All curl_easy_setopt() options are documented at:
66 * https://curl.haxx.se/libcurl/c/curl_easy_setopt.html
67 ************************************************************************/
68#include <curl/curl.h>
69
70int main(int argc, char *argv[])
71{
72  CURLcode ret;
73  CURL *hnd;
74
75  hnd = curl_easy_init();
76  curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
77  curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/1402");
78  curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "foo=bar&baz=quux");
79  curl_easy_setopt(hnd, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)16);
80  curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped");
81  curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
82  curl_easy_setopt(hnd, CURLOPT_HTTP09_ALLOWED, 1L);
83  curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
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 select to either not use them or implement
88     them yourself.
89
90  CURLOPT_WRITEDATA set to a objectpointer
91  CURLOPT_INTERLEAVEDATA set to a objectpointer
92  CURLOPT_WRITEFUNCTION set to a functionpointer
93  CURLOPT_READDATA set to a objectpointer
94  CURLOPT_READFUNCTION set to a functionpointer
95  CURLOPT_SEEKDATA set to a objectpointer
96  CURLOPT_SEEKFUNCTION set to a functionpointer
97  CURLOPT_ERRORBUFFER set to a objectpointer
98  CURLOPT_STDERR set to a objectpointer
99  CURLOPT_DEBUGFUNCTION set to a functionpointer
100  CURLOPT_DEBUGDATA set to a objectpointer
101  CURLOPT_HEADERFUNCTION set to a functionpointer
102  CURLOPT_HEADERDATA set to a objectpointer
103
104  */
105
106  ret = curl_easy_perform(hnd);
107
108  curl_easy_cleanup(hnd);
109  hnd = NULL;
110
111  return (int)ret;
112}
113/**** End of sample code ****/
114</file>
115</verify>
116</testcase>
117