2012-02-23 17:48:46 +08:00
|
|
|
<testcase>
|
|
|
|
<info>
|
|
|
|
<keywords>
|
|
|
|
HTTP
|
2012-03-23 01:32:19 +08:00
|
|
|
HTTP GET
|
2012-02-23 17:48:46 +08:00
|
|
|
HTTP Basic auth
|
2012-03-23 01:32:19 +08:00
|
|
|
HTTP set cookie
|
|
|
|
cookies
|
2012-02-23 17:48:46 +08:00
|
|
|
--libcurl
|
|
|
|
</keywords>
|
|
|
|
</info>
|
|
|
|
|
|
|
|
# Server-side
|
|
|
|
<reply>
|
|
|
|
<data>
|
|
|
|
HTTP/1.1 200 OK
|
|
|
|
Date: Thu, 29 Jul 2008 14:49:00 GMT
|
|
|
|
Server: test-server/fake
|
|
|
|
Content-Length: 0
|
|
|
|
Content-Type: text/plain
|
|
|
|
Connection: close
|
|
|
|
|
|
|
|
</data>
|
|
|
|
</reply>
|
|
|
|
|
|
|
|
# Client-side
|
|
|
|
<client>
|
|
|
|
<server>
|
|
|
|
http
|
|
|
|
</server>
|
|
|
|
<name>
|
|
|
|
--libcurl for GET with various options
|
|
|
|
</name>
|
2022-09-15 19:30:09 +08:00
|
|
|
<features>
|
|
|
|
http
|
|
|
|
ftp
|
|
|
|
file
|
|
|
|
</features>
|
2017-03-13 05:33:56 +08:00
|
|
|
<setenv>
|
|
|
|
SSL_CERT_FILE=
|
|
|
|
</setenv>
|
2012-02-23 17:48:46 +08:00
|
|
|
<command>
|
2023-03-29 09:20:54 +08:00
|
|
|
http://%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"
|
2012-02-23 17:48:46 +08:00
|
|
|
</command>
|
|
|
|
</client>
|
|
|
|
|
|
|
|
# Verify data after the test has been "shot"
|
|
|
|
<verify>
|
|
|
|
<protocol>
|
2021-03-13 00:38:26 +08:00
|
|
|
GET /we/want/%TESTNUMBER HTTP/1.1
|
2015-03-12 07:50:46 +08:00
|
|
|
Host: %HOSTIP:%HTTPPORT
|
2012-02-24 06:13:42 +08:00
|
|
|
Authorization: Basic ZmFrZTp1c2Vy
|
2020-10-02 19:45:24 +08:00
|
|
|
User-Agent: MyUA
|
2012-02-24 06:13:42 +08:00
|
|
|
Accept: */*
|
|
|
|
Cookie: chocolate=chip
|
|
|
|
X-Files: Mulder
|
|
|
|
X-Men: cyclops, iceman
|
|
|
|
|
2012-02-23 17:48:46 +08:00
|
|
|
</protocol>
|
|
|
|
<stripfile>
|
2015-12-13 16:24:08 +08:00
|
|
|
# CURLOPT_SSL_VERIFYPEER, SSH_KNOWNHOSTS and HTTP_VERSION vary with
|
|
|
|
# configurations - just ignore them
|
2012-02-23 17:48:46 +08:00
|
|
|
$_ = '' if /CURLOPT_SSL_VERIFYPEER/
|
2012-02-24 06:13:42 +08:00
|
|
|
$_ = '' if /CURLOPT_SSH_KNOWNHOSTS/
|
2015-12-13 16:24:08 +08:00
|
|
|
$_ = '' if /CURLOPT_HTTP_VERSION/
|
2019-05-14 16:03:54 +08:00
|
|
|
$_ = '' if /CURLOPT_INTERLEAVEDATA/
|
2012-02-23 17:48:46 +08:00
|
|
|
</stripfile>
|
2023-03-29 09:20:54 +08:00
|
|
|
<file name="%LOGDIR/test%TESTNUMBER.c" mode="text">
|
2012-02-23 17:48:46 +08:00
|
|
|
/********* Sample code generated by the curl command line tool **********
|
|
|
|
* All curl_easy_setopt() options are documented at:
|
2020-11-04 21:02:01 +08:00
|
|
|
* https://curl.se/libcurl/c/curl_easy_setopt.html
|
2012-02-23 17:48:46 +08:00
|
|
|
************************************************************************/
|
|
|
|
#include <curl/curl.h>
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
CURLcode ret;
|
|
|
|
CURL *hnd;
|
|
|
|
struct curl_slist *slist1;
|
|
|
|
|
|
|
|
slist1 = NULL;
|
|
|
|
slist1 = curl_slist_append(slist1, "X-Files: Mulder");
|
|
|
|
slist1 = curl_slist_append(slist1, "X-Men: cyclops, iceman");
|
|
|
|
|
|
|
|
hnd = curl_easy_init();
|
2017-04-24 18:03:08 +08:00
|
|
|
curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
|
2021-03-13 00:38:26 +08:00
|
|
|
curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER");
|
2012-02-23 17:48:46 +08:00
|
|
|
curl_easy_setopt(hnd, CURLOPT_USERPWD, "fake:user");
|
2017-09-30 07:20:56 +08:00
|
|
|
curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC);
|
2012-02-23 17:48:46 +08:00
|
|
|
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, slist1);
|
2017-09-30 07:20:56 +08:00
|
|
|
curl_easy_setopt(hnd, CURLOPT_USERAGENT, "MyUA");
|
2012-02-23 17:48:46 +08:00
|
|
|
curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
|
|
|
|
curl_easy_setopt(hnd, CURLOPT_COOKIE, "chocolate=chip");
|
|
|
|
curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
|
2020-12-11 20:55:00 +08:00
|
|
|
%if ftp
|
2020-11-24 21:56:57 +08:00
|
|
|
curl_easy_setopt(hnd, CURLOPT_FTP_SKIP_PASV_IP, 1L);
|
2020-12-11 20:55:00 +08:00
|
|
|
%endif
|
2012-02-23 17:48:46 +08:00
|
|
|
curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);
|
2022-09-21 16:41:22 +08:00
|
|
|
curl_easy_setopt(hnd, CURLOPT_PROTOCOLS_STR, "file,ftp,http");
|
2012-02-23 17:48:46 +08:00
|
|
|
|
|
|
|
/* Here is a list of options the curl code used that cannot get generated
|
2021-10-01 22:57:00 +08:00
|
|
|
as source easily. You may choose to either not use them or implement
|
2012-02-23 17:48:46 +08:00
|
|
|
them yourself.
|
|
|
|
|
2022-09-12 05:59:38 +08:00
|
|
|
CURLOPT_WRITEDATA was set to an object pointer
|
|
|
|
CURLOPT_WRITEFUNCTION was set to a function pointer
|
|
|
|
CURLOPT_READDATA was set to an object pointer
|
|
|
|
CURLOPT_READFUNCTION was set to a function pointer
|
|
|
|
CURLOPT_SEEKDATA was set to an object pointer
|
|
|
|
CURLOPT_SEEKFUNCTION was set to a function pointer
|
|
|
|
CURLOPT_ERRORBUFFER was set to an object pointer
|
|
|
|
CURLOPT_STDERR was set to an object pointer
|
|
|
|
CURLOPT_DEBUGFUNCTION was set to a function pointer
|
|
|
|
CURLOPT_DEBUGDATA was set to an object pointer
|
|
|
|
CURLOPT_HEADERFUNCTION was set to a function pointer
|
|
|
|
CURLOPT_HEADERDATA was set to an object pointer
|
2012-02-23 17:48:46 +08:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
ret = curl_easy_perform(hnd);
|
|
|
|
|
|
|
|
curl_easy_cleanup(hnd);
|
|
|
|
hnd = NULL;
|
|
|
|
curl_slist_free_all(slist1);
|
|
|
|
slist1 = NULL;
|
|
|
|
|
|
|
|
return (int)ret;
|
|
|
|
}
|
|
|
|
/**** End of sample code ****/
|
|
|
|
</file>
|
|
|
|
</verify>
|
|
|
|
</testcase>
|