quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

test1401 (3489B)


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