quickjs-tart

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

test1402 (3054B)


      1 <testcase>
      2 <info>
      3 <keywords>
      4 HTTP
      5 HTTP POST
      6 --libcurl
      7 </keywords>
      8 </info>
      9 
     10 # Server-side
     11 <reply>
     12 <data>
     13 HTTP/1.1 200 OK
     14 Date: Thu, 29 Jul 2008 14:49:00 GMT
     15 Server: test-server/fake
     16 Content-Length: 0
     17 Content-Type: text/plain
     18 Connection: close
     19 
     20 </data>
     21 </reply>
     22 
     23 # Client-side
     24 <client>
     25 <features>
     26 --libcurl
     27 </features>
     28 <server>
     29 http
     30 </server>
     31 <name>
     32 --libcurl for simple POST
     33 </name>
     34 <setenv>
     35 SSL_CERT_FILE=
     36 </setenv>
     37 <command>
     38 http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER --libcurl %LOGDIR/test%TESTNUMBER.c -d "foo=bar" -d "baz=quux"
     39 </command>
     40 </client>
     41 
     42 # Verify data after the test has been "shot"
     43 <verify>
     44 <protocol nonewline="yes">
     45 POST /we/want/%TESTNUMBER HTTP/1.1
     46 Host: %HOSTIP:%HTTPPORT
     47 User-Agent: curl/%VERSION
     48 Accept: */*
     49 Content-Length: 16
     50 Content-Type: application/x-www-form-urlencoded
     51 
     52 foo=bar&baz=quux
     53 </protocol>
     54 <stripfile>
     55 # curl's default user-agent varies with version, libraries etc.
     56 s/(USERAGENT, \")[^\"]+/${1}stripped/
     57 # CURLOPT_SSL_VERIFYPEER, SSH_KNOWNHOSTS and HTTP_VERSION vary with
     58 # configurations - just ignore them
     59 $_ = '' if /CURLOPT_SSL_VERIFYPEER/
     60 $_ = '' if /CURLOPT_SSH_KNOWNHOSTS/
     61 $_ = '' if /CURLOPT_HTTP_VERSION/
     62 $_ = '' if /CURLOPT_INTERLEAVEDATA/
     63 </stripfile>
     64 <file name="%LOGDIR/test%TESTNUMBER.c" mode="text">
     65 /********* Sample code generated by the curl command line tool **********
     66  * All curl_easy_setopt() options are documented at:
     67  * https://curl.se/libcurl/c/curl_easy_setopt.html
     68  ************************************************************************/
     69 #include <curl/curl.h>
     70 
     71 int main(int argc, char *argv[])
     72 {
     73   CURLcode ret;
     74   CURL *hnd;
     75 
     76   hnd = curl_easy_init();
     77   curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
     78   curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
     79   curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER");
     80   curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "foo=bar&baz=quux");
     81   curl_easy_setopt(hnd, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)16);
     82   curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped");
     83   curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
     84   curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);
     85 
     86   /* Here is a list of options the curl code used that cannot get generated
     87      as source easily. You may choose to either not use them or implement
     88      them yourself.
     89 
     90   CURLOPT_DEBUGFUNCTION was set to a function pointer
     91   CURLOPT_DEBUGDATA was set to an object pointer
     92   CURLOPT_WRITEDATA was set to an object pointer
     93   CURLOPT_WRITEFUNCTION was set to a function pointer
     94   CURLOPT_READDATA was set to an object pointer
     95   CURLOPT_READFUNCTION was set to a function pointer
     96   CURLOPT_SEEKDATA was set to an object pointer
     97   CURLOPT_SEEKFUNCTION was set to a function pointer
     98   CURLOPT_HEADERFUNCTION was set to a function pointer
     99   CURLOPT_HEADERDATA was set to an object pointer
    100   CURLOPT_ERRORBUFFER was set to an object pointer
    101   CURLOPT_STDERR was set to an object pointer
    102 
    103   */
    104 
    105   ret = curl_easy_perform(hnd);
    106 
    107   curl_easy_cleanup(hnd);
    108   hnd = NULL;
    109 
    110   return (int)ret;
    111 }
    112 /**** End of sample code ****/
    113 </file>
    114 </verify>
    115 </testcase>