Annotation of embedaddon/curl/tests/data/test1404, revision 1.1.1.1

1.1       misho       1: <testcase>
                      2: # Based on test 1315
                      3: <info>
                      4: <keywords>
                      5: HTTP
                      6: HTTP FORMPOST
                      7: HTTP file upload
                      8: --libcurl
                      9: </keywords>
                     10: </info>
                     11: 
                     12: # Server-side
                     13: <reply>
                     14: <data>
                     15: HTTP/1.1 200 OK
                     16: Date: Thu, 29 Jul 2008 14:49:00 GMT
                     17: Server: test-server/fake
                     18: Content-Length: 0
                     19: Connection: close
                     20: 
                     21: </data>
                     22: </reply>
                     23: 
                     24: # Client-side
                     25: <client>
                     26: <server>
                     27: http
                     28: </server>
                     29:  <name>
                     30: --libcurl for HTTP RFC1867-type formposting - -F with 3 files, one with explicit type & encoder
                     31:  </name>
                     32: <setenv>
                     33: SSL_CERT_FILE=
                     34: </setenv>
                     35:  <command>
                     36: http://%HOSTIP:%HTTPPORT/we/want/1404 -F name=value -F 'file=@log/test1404.txt,log/test1404.txt;type=magic/content;encoder=8bit,log/test1404.txt;headers=X-testheader-1: header 1;headers=X-testheader-2: header 2' --libcurl log/test1404.c
                     37: </command>
                     38: # We create this file before the command is invoked!
                     39: <file name="log/test1404.txt">
                     40: dummy data
                     41: </file>
                     42: </client>
                     43: 
                     44: # Verify data after the test has been "shot"
                     45: <verify>
                     46: <strip>
                     47: (^User-Agent:.*|-----+\w+)
                     48: </strip>
                     49: <protocol>
                     50: POST /we/want/1404 HTTP/1.1
                     51: User-Agent: curl/7.18.2 (i686-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.7a ipv6 zlib/1.1.4
                     52: Host: %HOSTIP:%HTTPPORT
                     53: Accept: */*
                     54: Content-Length: 882
                     55: Content-Type: multipart/form-data; boundary=----------------------------9ef8d6205763
                     56: 
                     57: ------------------------------9ef8d6205763
                     58: Content-Disposition: form-data; name="name"
                     59: 
                     60: value
                     61: ------------------------------9ef8d6205763
                     62: Content-Disposition: form-data; name="file"
                     63: Content-Type: multipart/mixed; boundary=----------------------------aaaaaaaaaaaa
                     64: 
                     65: Content-Disposition: attachment; filename="test1404.txt"
                     66: Content-Type: text/plain
                     67: 
                     68: dummy data
                     69: 
                     70: ------------------------------9ef8d6205763
                     71: Content-Disposition: attachment; filename="test1404.txt"
                     72: Content-Type: magic/content
                     73: Content-Transfer-Encoding: 8bit
                     74: 
                     75: dummy data
                     76: 
                     77: ------------------------------9ef8d6205763
                     78: Content-Disposition: attachment; filename="test1404.txt"
                     79: Content-Type: text/plain
                     80: X-testheader-1: header 1
                     81: X-testheader-2: header 2
                     82: 
                     83: dummy data
                     84: 
                     85: ------------------------------aaaaaaaaaaaa--
                     86: 
                     87: ------------------------------9ef8d6205763--
                     88: </protocol>
                     89: <stripfile>
                     90: # curl's default user-agent varies with version, libraries etc.
                     91: s/(USERAGENT, \")[^\"]+/${1}stripped/
                     92: # CURLOPT_SSL_VERIFYPEER, SSH_KNOWNHOSTS and HTTP_VERSION vary with
                     93: # configurations - just ignore them
                     94: $_ = '' if /CURLOPT_SSL_VERIFYPEER/
                     95: $_ = '' if /CURLOPT_SSH_KNOWNHOSTS/
                     96: $_ = '' if /CURLOPT_HTTP_VERSION/
                     97: $_ = '' if /CURLOPT_INTERLEAVEDATA/
                     98: # CURL_DOES_CONVERSION generates an extra comment.
                     99: $_ = '' if /\/\* "value" \*\//
                    100: </stripfile>
                    101: <file name="log/test1404.c" mode="text">
                    102: /********* Sample code generated by the curl command line tool **********
                    103:  * All curl_easy_setopt() options are documented at:
                    104:  * https://curl.haxx.se/libcurl/c/curl_easy_setopt.html
                    105:  ************************************************************************/
                    106: #include <curl/curl.h>
                    107: 
                    108: int main(int argc, char *argv[])
                    109: {
                    110:   CURLcode ret;
                    111:   CURL *hnd;
                    112:   curl_mime *mime1;
                    113:   curl_mimepart *part1;
                    114:   curl_mime *mime2;
                    115:   curl_mimepart *part2;
                    116:   struct curl_slist *slist1;
                    117: 
                    118:   mime1 = NULL;
                    119:   mime2 = NULL;
                    120:   slist1 = NULL;
                    121:   slist1 = curl_slist_append(slist1, "X-testheader-1: header 1");
                    122:   slist1 = curl_slist_append(slist1, "X-testheader-2: header 2");
                    123: 
                    124:   hnd = curl_easy_init();
                    125:   curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
                    126:   curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/1404");
                    127:   mime1 = curl_mime_init(hnd);
                    128:   part1 = curl_mime_addpart(mime1);
                    129:   curl_mime_data(part1, "value", CURL_ZERO_TERMINATED);
                    130:   curl_mime_name(part1, "name");
                    131:   part1 = curl_mime_addpart(mime1);
                    132:   mime2 = curl_mime_init(hnd);
                    133:   part2 = curl_mime_addpart(mime2);
                    134:   curl_mime_filedata(part2, "log/test1404.txt");
                    135:   part2 = curl_mime_addpart(mime2);
                    136:   curl_mime_filedata(part2, "log/test1404.txt");
                    137:   curl_mime_encoder(part2, "8bit");
                    138:   curl_mime_type(part2, "magic/content");
                    139:   part2 = curl_mime_addpart(mime2);
                    140:   curl_mime_filedata(part2, "log/test1404.txt");
                    141:   curl_mime_headers(part2, slist1, 1);
                    142:   slist1 = NULL;
                    143:   curl_mime_subparts(part1, mime2);
                    144:   mime2 = NULL;
                    145:   curl_mime_name(part1, "file");
                    146:   curl_easy_setopt(hnd, CURLOPT_MIMEPOST, mime1);
                    147:   curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped");
                    148:   curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
                    149:   curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
                    150:   curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);
                    151: 
                    152:   /* Here is a list of options the curl code used that cannot get generated
                    153:      as source easily. You may select to either not use them or implement
                    154:      them yourself.
                    155: 
                    156:   CURLOPT_WRITEDATA set to a objectpointer
                    157:   CURLOPT_WRITEFUNCTION set to a functionpointer
                    158:   CURLOPT_READDATA set to a objectpointer
                    159:   CURLOPT_READFUNCTION set to a functionpointer
                    160:   CURLOPT_SEEKDATA set to a objectpointer
                    161:   CURLOPT_SEEKFUNCTION set to a functionpointer
                    162:   CURLOPT_ERRORBUFFER set to a objectpointer
                    163:   CURLOPT_STDERR set to a objectpointer
                    164:   CURLOPT_DEBUGFUNCTION set to a functionpointer
                    165:   CURLOPT_DEBUGDATA set to a objectpointer
                    166:   CURLOPT_HEADERFUNCTION set to a functionpointer
                    167:   CURLOPT_HEADERDATA set to a objectpointer
                    168: 
                    169:   */
                    170: 
                    171:   ret = curl_easy_perform(hnd);
                    172: 
                    173:   curl_easy_cleanup(hnd);
                    174:   hnd = NULL;
                    175:   curl_mime_free(mime1);
                    176:   mime1 = NULL;
                    177:   curl_mime_free(mime2);
                    178:   mime2 = NULL;
                    179:   curl_slist_free_all(slist1);
                    180:   slist1 = NULL;
                    181: 
                    182:   return (int)ret;
                    183: }
                    184: /**** End of sample code ****/
                    185: </file>
                    186: </verify>
                    187: </testcase>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>