diff options
author | Daniel Stenberg <daniel@haxx.se> | 2015-10-24 00:52:25 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2015-11-02 08:41:46 +0100 |
commit | ca5f9341ef0a941ed478bc5c7e79397b68c2a616 (patch) | |
tree | 0e53c2d2a2c023b961d0baf634259e5e901c66b9 /tests | |
parent | 49a991346e9c6f334d014f16944744a1dac11c64 (diff) |
formadd: support >2GB files on windows
Closes #425
Diffstat (limited to 'tests')
-rw-r--r-- | tests/data/test554 | 47 | ||||
-rw-r--r-- | tests/libtest/lib554.c | 54 |
2 files changed, 86 insertions, 15 deletions
diff --git a/tests/data/test554 b/tests/data/test554 index b55fa3d10..fdbd1868b 100644 --- a/tests/data/test554 +++ b/tests/data/test554 @@ -18,6 +18,22 @@ Content-Type: text/html hello </data> +<datacheck> +HTTP/1.1 200 OK
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake swsclose
+Connection: close
+Content-Type: text/html
+
+hello +HTTP/1.1 200 OK
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake swsclose
+Connection: close
+Content-Type: text/html
+
+hello +</datacheck> </reply> # Client-side @@ -80,6 +96,37 @@ Content-Type: text/plain blah blah
--------------------------------
+POST /554 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+Accept: */*
+Content-Length: 732
+Expect: 100-continue
+Content-Type: multipart/form-data; boundary=----------------------------
+
+------------------------------
+Content-Disposition: form-data; name="sendfile alternative"; filename="file name 2"
+
+this is what we post to the silly web server +
+------------------------------
+Content-Disposition: form-data; name="callbackdata"
+
+this is what we post to the silly web server +
+------------------------------
+Content-Disposition: form-data; name="filename"
+
+postit2.c
+------------------------------
+Content-Disposition: form-data; name="submit"
+
+send
+------------------------------
+Content-Disposition: form-data; name="somename"; filename="somefile.txt"
+Content-Type: text/plain
+
+blah blah
+--------------------------------
</protocol> </verify> </testcase> diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c index 0596f3ef1..c54d99e86 100644 --- a/tests/libtest/lib554.c +++ b/tests/libtest/lib554.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -64,7 +64,7 @@ static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp) #endif } -int test(char *URL) +static int once(char *URL, bool oldstyle) { CURL *curl; CURLcode res=CURLE_OK; @@ -75,22 +75,29 @@ int test(char *URL) struct WriteThis pooh; struct WriteThis pooh2; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { - fprintf(stderr, "curl_global_init() failed\n"); - return TEST_ERR_MAJOR_BAD; - } - pooh.readptr = data; pooh.sizeleft = strlen(data); /* Fill in the file upload field */ - formrc = curl_formadd(&formpost, - &lastptr, - CURLFORM_COPYNAME, "sendfile", - CURLFORM_STREAM, &pooh, - CURLFORM_CONTENTSLENGTH, (long)pooh.sizeleft, - CURLFORM_FILENAME, "postit2.c", - CURLFORM_END); + if(oldstyle) { + formrc = curl_formadd(&formpost, + &lastptr, + CURLFORM_COPYNAME, "sendfile", + CURLFORM_STREAM, &pooh, + CURLFORM_CONTENTSLENGTH, (long)pooh.sizeleft, + CURLFORM_FILENAME, "postit2.c", + CURLFORM_END); + } + else { + /* new style */ + formrc = curl_formadd(&formpost, + &lastptr, + CURLFORM_COPYNAME, "sendfile alternative", + CURLFORM_STREAM, &pooh, + CURLFORM_CONTENTLEN, (curl_off_t)pooh.sizeleft, + CURLFORM_FILENAME, "file name 2", + CURLFORM_END); + } if(formrc) printf("curl_formadd(1) = %d\n", (int)formrc); @@ -190,10 +197,27 @@ test_cleanup: /* always cleanup */ curl_easy_cleanup(curl); - curl_global_cleanup(); /* now cleanup the formpost chain */ curl_formfree(formpost); return res; } + +int test(char *URL) +{ + int res; + + if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + fprintf(stderr, "curl_global_init() failed\n"); + return TEST_ERR_MAJOR_BAD; + } + + res = once(URL, TRUE); /* old */ + if(!res) + res = once(URL, FALSE); /* new */ + + curl_global_cleanup(); + + return res; +} |