summaryrefslogtreecommitdiff
path: root/tests/data/test1404
diff options
context:
space:
mode:
authorPatrick Monnerat <patrick@monnerat.net>2017-09-02 19:08:45 +0100
committerPatrick Monnerat <patrick@monnerat.net>2017-09-02 19:08:45 +0100
commit3baf36edf6ed1d7c74d68846d79f87334b573aea (patch)
tree3946a907baae28c177dd65b4424deb7370d3d58c /tests/data/test1404
parentfec7a858b88c86e97e5dc96414a01feb21a2b661 (diff)
downloadcurl-3baf36edf6ed1d7c74d68846d79f87334b573aea.tar.gz
mime: tests and examples.
Additional mime-specific tests. Existing tests updated to reflect small differences (Expect: 100-continue, data size change due to empty lines, etc). Option -F headers= keyword added to tests. test1135 disabled until the entry point order change is resolved. New example smtp-mime. Examples postit2 and multi-post converted from form API to mime API.
Diffstat (limited to 'tests/data/test1404')
-rw-r--r--tests/data/test140463
1 files changed, 40 insertions, 23 deletions
diff --git a/tests/data/test1404 b/tests/data/test1404
index c86d2602c..60ed58a16 100644
--- a/tests/data/test1404
+++ b/tests/data/test1404
@@ -33,7 +33,7 @@ http
SSL_CERT_FILE=
</setenv>
<command>
-http://%HOSTIP:%HTTPPORT/we/want/1404 -F name=value -F 'file=@log/test1404.txt,log/test1404.txt;type=magic/content,log/test1404.txt' --libcurl log/test1404.c
+http://%HOSTIP:%HTTPPORT/we/want/1404 -F name=value -F 'file=@log/test1404.txt,log/test1404.txt;type=magic/content,log/test1404.txt;headers=X-testheader-1: header 1;headers=X-testheader-2: header 2' --libcurl log/test1404.c
</command>
# We create this file before the command is invoked!
<file name="log/test1404.txt">
@@ -51,8 +51,7 @@ POST /we/want/1404 HTTP/1.1
User-Agent: curl/7.18.2 (i686-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.7a ipv6 zlib/1.1.4
Host: %HOSTIP:%HTTPPORT
Accept: */*
-Content-Length: 795
-Expect: 100-continue
+Content-Length: 849
Content-Type: multipart/form-data; boundary=----------------------------9ef8d6205763
------------------------------9ef8d6205763
@@ -77,10 +76,13 @@ dummy data
------------------------------9ef8d6205763
Content-Disposition: attachment; filename="test1404.txt"
Content-Type: text/plain
+X-testheader-1: header 1
+X-testheader-2: header 2
dummy data
------------------------------aaaaaaaaaaaa--
+
------------------------------9ef8d6205763--
</protocol>
<stripfile>
@@ -103,30 +105,41 @@ int main(int argc, char *argv[])
{
CURLcode ret;
CURL *hnd;
- struct curl_httppost *post1;
- struct curl_httppost *postend;
+ curl_mime *mime1;
+ curl_mimepart *part1;
+ curl_mime *mime2;
+ curl_mimepart *part2;
+ struct curl_slist *slist1;
- post1 = NULL;
- postend = NULL;
- curl_formadd(&post1, &postend,
- CURLFORM_COPYNAME, "name",
- CURLFORM_COPYCONTENTS, "value",
- CURLFORM_END);
- curl_formadd(&post1, &postend,
- CURLFORM_COPYNAME, "file",
- CURLFORM_FILE, "log/test1404.txt",
- CURLFORM_CONTENTTYPE, "text/plain",
- CURLFORM_FILE, "log/test1404.txt",
- CURLFORM_CONTENTTYPE, "magic/content",
- CURLFORM_FILE, "log/test1404.txt",
- CURLFORM_CONTENTTYPE, "text/plain",
- CURLFORM_END);
+ mime1 = NULL;
+ mime2 = NULL;
+ slist1 = NULL;
+ slist1 = curl_slist_append(slist1, "X-testheader-1: header 1");
+ slist1 = curl_slist_append(slist1, "X-testheader-2: header 2");
hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/1404");
curl_easy_setopt(hnd, CURLOPT_HEADER, 1L);
- curl_easy_setopt(hnd, CURLOPT_HTTPPOST, post1);
+ mime1 = curl_mime_init(hnd);
+ part1 = curl_mime_addpart(mime1);
+ curl_mime_data(part1, "value", -1);
+ curl_mime_name(part1, "name", -1);
+ part1 = curl_mime_addpart(mime1);
+ mime2 = curl_mime_init(hnd);
+ part2 = curl_mime_addpart(mime2);
+ curl_mime_filedata(part2, "log/test1404.txt");
+ part2 = curl_mime_addpart(mime2);
+ curl_mime_filedata(part2, "log/test1404.txt");
+ curl_mime_type(part2, "magic/content");
+ part2 = curl_mime_addpart(mime2);
+ curl_mime_filedata(part2, "log/test1404.txt");
+ curl_mime_headers(part2, slist1, 1);
+ slist1 = NULL;
+ curl_mime_subparts(part1, mime2);
+ mime2 = NULL;
+ curl_mime_name(part1, "file", -1);
+ curl_easy_setopt(hnd, CURLOPT_MIMEPOST, mime1);
curl_easy_setopt(hnd, CURLOPT_USERAGENT, "stripped");
curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
@@ -156,8 +169,12 @@ int main(int argc, char *argv[])
curl_easy_cleanup(hnd);
hnd = NULL;
- curl_formfree(post1);
- post1 = NULL;
+ curl_mime_free(mime1);
+ mime1 = NULL;
+ curl_mime_free(mime2);
+ mime2 = NULL;
+ curl_slist_free_all(slist1);
+ slist1 = NULL;
return (int)ret;
}