xref: /curl/tests/data/test1401 (revision 361cd3ed)
1<testcase>
2<info>
3<keywords>
4HTTP
5HTTP GET
6HTTP Basic auth
7HTTP set cookie
8cookies
9--libcurl
10</keywords>
11</info>
12
13# Server-side
14<reply>
15<data>
16HTTP/1.1 200 OK
17Date: Thu, 29 Jul 2008 14:49:00 GMT
18Server: test-server/fake
19Content-Length: 0
20Content-Type: text/plain
21Connection: close
22
23</data>
24</reply>
25
26# Client-side
27<client>
28<server>
29http
30</server>
31<name>
32--libcurl for GET with various options
33</name>
34<features>
35http
36ftp
37file
38cookies
39</features>
40<setenv>
41SSL_CERT_FILE=
42</setenv>
43<command>
44http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER --libcurl %LOGDIR/test%TESTNUMBER.c --basic -u fake:user -H "X-Files: Mulder" -H "X-Men: cyclops, iceman" -A MyUA -b chocolate=chip --proto "=http,ftp,file"
45</command>
46</client>
47
48# Verify data after the test has been "shot"
49<verify>
50<protocol>
51GET /we/want/%TESTNUMBER HTTP/1.1
52Host: %HOSTIP:%HTTPPORT
53Authorization: Basic ZmFrZTp1c2Vy
54User-Agent: MyUA
55Accept: */*
56Cookie: chocolate=chip
57X-Files: Mulder
58X-Men: cyclops, iceman
59
60</protocol>
61<stripfile>
62# CURLOPT_SSL_VERIFYPEER, SSH_KNOWNHOSTS and HTTP_VERSION vary with
63# configurations - just ignore them
64$_ = '' if /CURLOPT_SSL_VERIFYPEER/
65$_ = '' if /CURLOPT_SSH_KNOWNHOSTS/
66$_ = '' if /CURLOPT_HTTP_VERSION/
67$_ = '' if /CURLOPT_INTERLEAVEDATA/
68</stripfile>
69<file name="%LOGDIR/test%TESTNUMBER.c" mode="text">
70/********* Sample code generated by the curl command line tool **********
71 * All curl_easy_setopt() options are documented at:
72 * https://curl.se/libcurl/c/curl_easy_setopt.html
73 ************************************************************************/
74#include <curl/curl.h>
75
76int main(int argc, char *argv[])
77{
78  CURLcode ret;
79  CURL *hnd;
80  struct curl_slist *slist1;
81
82  slist1 = NULL;
83  slist1 = curl_slist_append(slist1, "X-Files: Mulder");
84  slist1 = curl_slist_append(slist1, "X-Men: cyclops, iceman");
85
86  hnd = curl_easy_init();
87  curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
88  curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER");
89  curl_easy_setopt(hnd, CURLOPT_USERPWD, "fake:user");
90  curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC);
91  curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, slist1);
92  curl_easy_setopt(hnd, CURLOPT_USERAGENT, "MyUA");
93  curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
94  curl_easy_setopt(hnd, CURLOPT_COOKIE, "chocolate=chip");
95  curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
96%if ftp
97  curl_easy_setopt(hnd, CURLOPT_FTP_SKIP_PASV_IP, 1L);
98%endif
99  curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);
100  curl_easy_setopt(hnd, CURLOPT_PROTOCOLS_STR, "file,ftp,http");
101
102  /* Here is a list of options the curl code used that cannot get generated
103     as source easily. You may choose to either not use them or implement
104     them yourself.
105
106  CURLOPT_WRITEDATA was set to an object pointer
107  CURLOPT_WRITEFUNCTION was set to a function pointer
108  CURLOPT_READDATA was set to an object pointer
109  CURLOPT_READFUNCTION was set to a function pointer
110  CURLOPT_SEEKDATA was set to an object pointer
111  CURLOPT_SEEKFUNCTION was set to a function pointer
112  CURLOPT_ERRORBUFFER was set to an object pointer
113  CURLOPT_STDERR was set to an object pointer
114  CURLOPT_DEBUGFUNCTION was set to a function pointer
115  CURLOPT_DEBUGDATA was set to an object pointer
116  CURLOPT_HEADERFUNCTION was set to a function pointer
117  CURLOPT_HEADERDATA was set to an object pointer
118
119  */
120
121  ret = curl_easy_perform(hnd);
122
123  curl_easy_cleanup(hnd);
124  hnd = NULL;
125  curl_slist_free_all(slist1);
126  slist1 = NULL;
127
128  return (int)ret;
129}
130/**** End of sample code ****/
131</file>
132</verify>
133</testcase>
134