quickjs-tart

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

test1465 (3216B)


      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 <server>
     26 http
     27 </server>
     28 <name>
     29 --libcurl for POST with binary content
     30 </name>
     31 <setenv>
     32 SSL_CERT_FILE=
     33 </setenv>
     34 <command>
     35 http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER --libcurl %LOGDIR/test%TESTNUMBER.c --data-binary @%LOGDIR/%TESTNUMBER-upload
     36 </command>
     37 # "ab\x81""cd\0e\\\"?\r\n\t\x01""fghi%x1Ajklm%xFD"
     38 <file name="%LOGDIR/%TESTNUMBER-upload" nonewline="yes">
     39 %hex[ab%81cd%00e\"?%0D%0A%09%01fghi%1Ajklm%FD]hex%
     40 </file>
     41 <features>
     42 --libcurl
     43 </features>
     44 </client>
     45 
     46 # Verify data after the test has been "shot"
     47 <verify>
     48 <protocol nonewline="yes">
     49 POST /we/want/%TESTNUMBER HTTP/1.1
     50 Host: %HOSTIP:%HTTPPORT
     51 User-Agent: curl/%VERSION
     52 Accept: */*
     53 Content-Length: 24
     54 Content-Type: application/x-www-form-urlencoded
     55 
     56 %hex[ab%81cd%00e\"?%0D%0A%09%01fghi%1Ajklm%FD]hex%
     57 </protocol>
     58 <stripfile>
     59 
     60 # CURLOPT_SSL_VERIFYPEER, SSH_KNOWNHOSTS and HTTP_VERSION vary with
     61 # configurations - just ignore them
     62 $_ = '' if /CURLOPT_SSL_VERIFYPEER/
     63 $_ = '' if /CURLOPT_SSH_KNOWNHOSTS/
     64 $_ = '' if /CURLOPT_HTTP_VERSION/
     65 $_ = '' if /CURLOPT_INTERLEAVEDATA/
     66 </stripfile>
     67 <file name="%LOGDIR/test%TESTNUMBER.c" mode="text">
     68 /********* Sample code generated by the curl command line tool **********
     69  * All curl_easy_setopt() options are documented at:
     70  * https://curl.se/libcurl/c/curl_easy_setopt.html
     71  ************************************************************************/
     72 #include <curl/curl.h>
     73 
     74 int main(int argc, char *argv[])
     75 {
     76   CURLcode ret;
     77   CURL *hnd;
     78 
     79   hnd = curl_easy_init();
     80   curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
     81   curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
     82   curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/%TESTNUMBER");
     83   curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "ab\201cd\000e\\\"\?\r\n\t\001fghi\x1ajklm\xfd");
     84   curl_easy_setopt(hnd, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)24);
     85   curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/%VERSION");
     86   curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
     87   curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);
     88 
     89   /* Here is a list of options the curl code used that cannot get generated
     90      as source easily. You may choose to either not use them or implement
     91      them yourself.
     92 
     93   CURLOPT_DEBUGFUNCTION was set to a function pointer
     94   CURLOPT_DEBUGDATA was set to an object pointer
     95   CURLOPT_WRITEDATA was set to an object pointer
     96   CURLOPT_WRITEFUNCTION was set to a function pointer
     97   CURLOPT_READDATA was set to an object pointer
     98   CURLOPT_READFUNCTION was set to a function pointer
     99   CURLOPT_SEEKDATA was set to an object pointer
    100   CURLOPT_SEEKFUNCTION was set to a function pointer
    101   CURLOPT_HEADERFUNCTION was set to a function pointer
    102   CURLOPT_HEADERDATA was set to an object pointer
    103   CURLOPT_ERRORBUFFER was set to an object pointer
    104   CURLOPT_STDERR was set to an object pointer
    105 
    106   */
    107 
    108   ret = curl_easy_perform(hnd);
    109 
    110   curl_easy_cleanup(hnd);
    111   hnd = NULL;
    112 
    113   return (int)ret;
    114 }
    115 /**** End of sample code ****/
    116 </file>
    117 </verify>
    118 </testcase>