• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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<setenv>
35SSL_CERT_FILE=
36</setenv>
37 <command>
38http://%HOSTIP:%HTTPPORT/we/want/1401 --libcurl log/test1401.c --basic -u fake:user -H "X-Files: Mulder" -H "X-Men: cyclops, iceman" -A MyUA -b chocolate=chip --proto "=http,ftp,file"
39</command>
40</client>
41
42# Verify data after the test has been "shot"
43<verify>
44<strip>
45^User-Agent:.*
46</strip>
47<protocol>
48GET /we/want/1401 HTTP/1.1
49Host: %HOSTIP:%HTTPPORT
50User-Agent: stripped
51Authorization: Basic ZmFrZTp1c2Vy
52Accept: */*
53Cookie: chocolate=chip
54X-Files: Mulder
55X-Men: cyclops, iceman
56
57</protocol>
58<stripfile>
59# CURLOPT_SSL_VERIFYPEER, SSH_KNOWNHOSTS and HTTP_VERSION vary with
60# configurations - just ignore them
61$_ = '' if /CURLOPT_SSL_VERIFYPEER/
62$_ = '' if /CURLOPT_SSH_KNOWNHOSTS/
63$_ = '' if /CURLOPT_HTTP_VERSION/
64</stripfile>
65<file name="log/test1401.c" mode="text">
66/********* Sample code generated by the curl command line tool **********
67 * All curl_easy_setopt() options are documented at:
68 * https://curl.haxx.se/libcurl/c/curl_easy_setopt.html
69 ************************************************************************/
70#include <curl/curl.h>
71
72int main(int argc, char *argv[])
73{
74  CURLcode ret;
75  CURL *hnd;
76  struct curl_slist *slist1;
77
78  slist1 = NULL;
79  slist1 = curl_slist_append(slist1, "X-Files: Mulder");
80  slist1 = curl_slist_append(slist1, "X-Men: cyclops, iceman");
81
82  hnd = curl_easy_init();
83  curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
84  curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/1401");
85  curl_easy_setopt(hnd, CURLOPT_USERPWD, "fake:user");
86  curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC);
87  curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, slist1);
88  curl_easy_setopt(hnd, CURLOPT_USERAGENT, "MyUA");
89  curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
90  curl_easy_setopt(hnd, CURLOPT_HTTP09_ALLOWED, 1L);
91  curl_easy_setopt(hnd, CURLOPT_COOKIE, "chocolate=chip");
92  curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
93  curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);
94  curl_easy_setopt(hnd, CURLOPT_PROTOCOLS, (long)CURLPROTO_FILE |
95                                           (long)CURLPROTO_FTP |
96                                           (long)CURLPROTO_HTTP);
97
98  /* Here is a list of options the curl code used that cannot get generated
99     as source easily. You may select to either not use them or implement
100     them yourself.
101
102  CURLOPT_WRITEDATA set to a objectpointer
103  CURLOPT_INTERLEAVEDATA set to a objectpointer
104  CURLOPT_WRITEFUNCTION set to a functionpointer
105  CURLOPT_READDATA set to a objectpointer
106  CURLOPT_READFUNCTION set to a functionpointer
107  CURLOPT_SEEKDATA set to a objectpointer
108  CURLOPT_SEEKFUNCTION set to a functionpointer
109  CURLOPT_ERRORBUFFER set to a objectpointer
110  CURLOPT_STDERR set to a objectpointer
111  CURLOPT_DEBUGFUNCTION set to a functionpointer
112  CURLOPT_DEBUGDATA set to a objectpointer
113  CURLOPT_HEADERFUNCTION set to a functionpointer
114  CURLOPT_HEADERDATA set to a objectpointer
115
116  */
117
118  ret = curl_easy_perform(hnd);
119
120  curl_easy_cleanup(hnd);
121  hnd = NULL;
122  curl_slist_free_all(slist1);
123  slist1 = NULL;
124
125  return (int)ret;
126}
127/**** End of sample code ****/
128</file>
129</verify>
130</testcase>
131