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