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, SSH_KNOWNHOSTS and HTTP_VERSION vary with
     57 # configurations - just ignore them
     58 $_ = '' if /CURLOPT_SSL_VERIFYPEER/
     59 $_ = '' if /CURLOPT_SSH_KNOWNHOSTS/
     60 $_ = '' if /CURLOPT_HTTP_VERSION/
     61 </stripfile>
     62 <file name="log/test1401.c" mode="text">
     63 /********* Sample code generated by the curl command line tool **********
     64  * All curl_easy_setopt() options are documented at:
     65  * https://curl.haxx.se/libcurl/c/curl_easy_setopt.html
     66  ************************************************************************/
     67 #include <curl/curl.h>
     68 
     69 int main(int argc, char *argv[])
     70 {
     71   CURLcode ret;
     72   CURL *hnd;
     73   struct curl_slist *slist1;
     74 
     75   slist1 = NULL;
     76   slist1 = curl_slist_append(slist1, "X-Files: Mulder");
     77   slist1 = curl_slist_append(slist1, "X-Men: cyclops, iceman");
     78 
     79   hnd = curl_easy_init();
     80   curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/1401");
     81   curl_easy_setopt(hnd, CURLOPT_HEADER, 1L);
     82   curl_easy_setopt(hnd, CURLOPT_USERPWD, "fake:user");
     83   curl_easy_setopt(hnd, CURLOPT_USERAGENT, "MyUA");
     84   curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, slist1);
     85   curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
     86   curl_easy_setopt(hnd, CURLOPT_HTTPAUTH, (long)CURLAUTH_BASIC);
     87   curl_easy_setopt(hnd, CURLOPT_COOKIE, "chocolate=chip");
     88   curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
     89   curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);
     90   curl_easy_setopt(hnd, CURLOPT_PROTOCOLS, (long)CURLPROTO_FILE |
     91                                            (long)CURLPROTO_FTP |
     92                                            (long)CURLPROTO_HTTP);
     93 
     94   /* Here is a list of options the curl code used that cannot get generated
     95      as source easily. You may select to either not use them or implement
     96      them yourself.
     97 
     98   CURLOPT_WRITEDATA set to a objectpointer
     99   CURLOPT_INTERLEAVEDATA set to a objectpointer
    100   CURLOPT_WRITEFUNCTION set to a functionpointer
    101   CURLOPT_READDATA set to a objectpointer
    102   CURLOPT_READFUNCTION set to a functionpointer
    103   CURLOPT_SEEKDATA set to a objectpointer
    104   CURLOPT_SEEKFUNCTION set to a functionpointer
    105   CURLOPT_ERRORBUFFER set to a objectpointer
    106   CURLOPT_STDERR set to a objectpointer
    107   CURLOPT_DEBUGFUNCTION set to a functionpointer
    108   CURLOPT_DEBUGDATA set to a objectpointer
    109   CURLOPT_HEADERFUNCTION set to a functionpointer
    110   CURLOPT_HEADERDATA set to a objectpointer
    111 
    112   */
    113 
    114   ret = curl_easy_perform(hnd);
    115 
    116   curl_easy_cleanup(hnd);
    117   hnd = NULL;
    118   curl_slist_free_all(slist1);
    119   slist1 = NULL;
    120 
    121   return (int)ret;
    122 }
    123 /**** End of sample code ****/
    124 </file>
    125 <stdout>
    126 </stdout>
    127 </verify>
    128 </testcase>
    129