mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
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.
This commit is contained in:
parent
fec7a858b8
commit
3baf36edf6
@ -26,8 +26,8 @@ check_PROGRAMS = 10-at-a-time anyauthput cookie_interface debug fileupload \
|
|||||||
https multi-app multi-debugcallback multi-double multi-post multi-single \
|
https multi-app multi-debugcallback multi-double multi-post multi-single \
|
||||||
persistant post-callback postit2 sepheaders simple simplepost simplessl \
|
persistant post-callback postit2 sepheaders simple simplepost simplessl \
|
||||||
sendrecv httpcustomheader certinfo chkspeed ftpgetinfo ftp-wildcard \
|
sendrecv httpcustomheader certinfo chkspeed ftpgetinfo ftp-wildcard \
|
||||||
smtp-mail smtp-multi smtp-ssl smtp-tls smtp-vrfy smtp-expn rtsp \
|
smtp-mail smtp-mime smtp-multi smtp-ssl smtp-tls smtp-vrfy smtp-expn \
|
||||||
externalsocket resolve progressfunc pop3-retr pop3-list pop3-uidl \
|
rtsp externalsocket resolve progressfunc pop3-retr pop3-list pop3-uidl \
|
||||||
pop3-dele pop3-top pop3-stat pop3-noop pop3-ssl pop3-tls pop3-multi \
|
pop3-dele pop3-top pop3-stat pop3-noop pop3-ssl pop3-tls pop3-multi \
|
||||||
imap-list imap-lsub imap-fetch imap-store imap-append imap-examine \
|
imap-list imap-lsub imap-fetch imap-store imap-append imap-examine \
|
||||||
imap-search imap-create imap-delete imap-copy imap-noop imap-ssl \
|
imap-search imap-create imap-delete imap-copy imap-noop imap-ssl \
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -37,47 +37,43 @@ int main(void)
|
|||||||
CURLM *multi_handle;
|
CURLM *multi_handle;
|
||||||
int still_running;
|
int still_running;
|
||||||
|
|
||||||
struct curl_httppost *formpost=NULL;
|
curl_mime *form = NULL;
|
||||||
struct curl_httppost *lastptr=NULL;
|
curl_mimepart *field = NULL;
|
||||||
struct curl_slist *headerlist=NULL;
|
struct curl_slist *headerlist = NULL;
|
||||||
static const char buf[] = "Expect:";
|
static const char buf[] = "Expect:";
|
||||||
|
|
||||||
/* Fill in the file upload field. This makes libcurl load data from
|
|
||||||
the given file name when curl_easy_perform() is called. */
|
|
||||||
curl_formadd(&formpost,
|
|
||||||
&lastptr,
|
|
||||||
CURLFORM_COPYNAME, "sendfile",
|
|
||||||
CURLFORM_FILE, "postit2.c",
|
|
||||||
CURLFORM_END);
|
|
||||||
|
|
||||||
/* Fill in the filename field */
|
|
||||||
curl_formadd(&formpost,
|
|
||||||
&lastptr,
|
|
||||||
CURLFORM_COPYNAME, "filename",
|
|
||||||
CURLFORM_COPYCONTENTS, "postit2.c",
|
|
||||||
CURLFORM_END);
|
|
||||||
|
|
||||||
/* Fill in the submit field too, even if this is rarely needed */
|
|
||||||
curl_formadd(&formpost,
|
|
||||||
&lastptr,
|
|
||||||
CURLFORM_COPYNAME, "submit",
|
|
||||||
CURLFORM_COPYCONTENTS, "send",
|
|
||||||
CURLFORM_END);
|
|
||||||
|
|
||||||
curl = curl_easy_init();
|
curl = curl_easy_init();
|
||||||
multi_handle = curl_multi_init();
|
multi_handle = curl_multi_init();
|
||||||
|
|
||||||
/* initialize custom header list (stating that Expect: 100-continue is not
|
|
||||||
wanted */
|
|
||||||
headerlist = curl_slist_append(headerlist, buf);
|
|
||||||
if(curl && multi_handle) {
|
if(curl && multi_handle) {
|
||||||
|
/* Create the form */
|
||||||
|
form = curl_mime_init(curl);
|
||||||
|
|
||||||
|
/* Fill in the file upload field */
|
||||||
|
field = curl_mime_addpart(form);
|
||||||
|
curl_mime_name(field, "sendfile", -1);
|
||||||
|
curl_mime_filedata(field, "multi-post.c");
|
||||||
|
|
||||||
|
/* Fill in the filename field */
|
||||||
|
field = curl_mime_addpart(form);
|
||||||
|
curl_mime_name(field, "filename", -1);
|
||||||
|
curl_mime_data(field, "multi-post.c", -1);
|
||||||
|
|
||||||
|
/* Fill in the submit field too, even if this is rarely needed */
|
||||||
|
field = curl_mime_addpart(form);
|
||||||
|
curl_mime_name(field, "submit", -1);
|
||||||
|
curl_mime_data(field, "send", -1);
|
||||||
|
|
||||||
|
/* initialize custom header list (stating that Expect: 100-continue is not
|
||||||
|
wanted */
|
||||||
|
headerlist = curl_slist_append(headerlist, buf);
|
||||||
|
|
||||||
/* what URL that receives this POST */
|
/* what URL that receives this POST */
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, "http://www.example.com/upload.cgi");
|
curl_easy_setopt(curl, CURLOPT_URL, "http://www.example.com/upload.cgi");
|
||||||
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||||
|
|
||||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
|
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
|
||||||
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
|
curl_easy_setopt(curl, CURLOPT_MIMEPOST, form);
|
||||||
|
|
||||||
curl_multi_add_handle(multi_handle, curl);
|
curl_multi_add_handle(multi_handle, curl);
|
||||||
|
|
||||||
@ -161,8 +157,8 @@ int main(void)
|
|||||||
/* always cleanup */
|
/* always cleanup */
|
||||||
curl_easy_cleanup(curl);
|
curl_easy_cleanup(curl);
|
||||||
|
|
||||||
/* then cleanup the formpost chain */
|
/* then cleanup the form */
|
||||||
curl_formfree(formpost);
|
curl_mime_free(form);
|
||||||
|
|
||||||
/* free slist */
|
/* free slist */
|
||||||
curl_slist_free_all(headerlist);
|
curl_slist_free_all(headerlist);
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -47,46 +47,42 @@ int main(int argc, char *argv[])
|
|||||||
CURL *curl;
|
CURL *curl;
|
||||||
CURLcode res;
|
CURLcode res;
|
||||||
|
|
||||||
struct curl_httppost *formpost=NULL;
|
curl_mime *form = NULL;
|
||||||
struct curl_httppost *lastptr=NULL;
|
curl_mimepart *field = NULL;
|
||||||
struct curl_slist *headerlist=NULL;
|
struct curl_slist *headerlist = NULL;
|
||||||
static const char buf[] = "Expect:";
|
static const char buf[] = "Expect:";
|
||||||
|
|
||||||
curl_global_init(CURL_GLOBAL_ALL);
|
curl_global_init(CURL_GLOBAL_ALL);
|
||||||
|
|
||||||
/* Fill in the file upload field */
|
|
||||||
curl_formadd(&formpost,
|
|
||||||
&lastptr,
|
|
||||||
CURLFORM_COPYNAME, "sendfile",
|
|
||||||
CURLFORM_FILE, "postit2.c",
|
|
||||||
CURLFORM_END);
|
|
||||||
|
|
||||||
/* Fill in the filename field */
|
|
||||||
curl_formadd(&formpost,
|
|
||||||
&lastptr,
|
|
||||||
CURLFORM_COPYNAME, "filename",
|
|
||||||
CURLFORM_COPYCONTENTS, "postit2.c",
|
|
||||||
CURLFORM_END);
|
|
||||||
|
|
||||||
|
|
||||||
/* Fill in the submit field too, even if this is rarely needed */
|
|
||||||
curl_formadd(&formpost,
|
|
||||||
&lastptr,
|
|
||||||
CURLFORM_COPYNAME, "submit",
|
|
||||||
CURLFORM_COPYCONTENTS, "send",
|
|
||||||
CURLFORM_END);
|
|
||||||
|
|
||||||
curl = curl_easy_init();
|
curl = curl_easy_init();
|
||||||
/* initialize custom header list (stating that Expect: 100-continue is not
|
|
||||||
wanted */
|
|
||||||
headerlist = curl_slist_append(headerlist, buf);
|
|
||||||
if(curl) {
|
if(curl) {
|
||||||
|
/* Create the form */
|
||||||
|
form = curl_mime_init(curl);
|
||||||
|
|
||||||
|
/* Fill in the file upload field */
|
||||||
|
field = curl_mime_addpart(form);
|
||||||
|
curl_mime_name(field, "sendfile", -1);
|
||||||
|
curl_mime_filedata(field, "postit2.c");
|
||||||
|
|
||||||
|
/* Fill in the filename field */
|
||||||
|
field = curl_mime_addpart(form);
|
||||||
|
curl_mime_name(field, "filename", -1);
|
||||||
|
curl_mime_data(field, "postit2.c", -1);
|
||||||
|
|
||||||
|
/* Fill in the submit field too, even if this is rarely needed */
|
||||||
|
field = curl_mime_addpart(form);
|
||||||
|
curl_mime_name(field, "submit", -1);
|
||||||
|
curl_mime_data(field, "send", -1);
|
||||||
|
|
||||||
|
/* initialize custom header list (stating that Expect: 100-continue is not
|
||||||
|
wanted */
|
||||||
|
headerlist = curl_slist_append(headerlist, buf);
|
||||||
/* what URL that receives this POST */
|
/* what URL that receives this POST */
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/examplepost.cgi");
|
curl_easy_setopt(curl, CURLOPT_URL, "http://example.com/examplepost.cgi");
|
||||||
if((argc == 2) && (!strcmp(argv[1], "noexpectheader")))
|
if((argc == 2) && (!strcmp(argv[1], "noexpectheader")))
|
||||||
/* only disable 100-continue header if explicitly requested */
|
/* only disable 100-continue header if explicitly requested */
|
||||||
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
|
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
|
||||||
curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
|
curl_easy_setopt(curl, CURLOPT_MIMEPOST, form);
|
||||||
|
|
||||||
/* Perform the request, res will get the return code */
|
/* Perform the request, res will get the return code */
|
||||||
res = curl_easy_perform(curl);
|
res = curl_easy_perform(curl);
|
||||||
@ -98,8 +94,8 @@ int main(int argc, char *argv[])
|
|||||||
/* always cleanup */
|
/* always cleanup */
|
||||||
curl_easy_cleanup(curl);
|
curl_easy_cleanup(curl);
|
||||||
|
|
||||||
/* then cleanup the formpost chain */
|
/* then cleanup the form */
|
||||||
curl_formfree(formpost);
|
curl_mime_free(form);
|
||||||
/* free slist */
|
/* free slist */
|
||||||
curl_slist_free_all(headerlist);
|
curl_slist_free_all(headerlist);
|
||||||
}
|
}
|
||||||
|
159
docs/examples/smtp-mime.c
Normal file
159
docs/examples/smtp-mime.c
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* _ _ ____ _
|
||||||
|
* Project ___| | | | _ \| |
|
||||||
|
* / __| | | | |_) | |
|
||||||
|
* | (__| |_| | _ <| |___
|
||||||
|
* \___|\___/|_| \_\_____|
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998 - 2017, 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
|
||||||
|
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||||
|
*
|
||||||
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||||
|
* copies of the Software, and permit persons to whom the Software is
|
||||||
|
* furnished to do so, under the terms of the COPYING file.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/* <DESC>
|
||||||
|
* SMTP example showing how to send mime e-mails
|
||||||
|
* </DESC>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <curl/curl.h>
|
||||||
|
|
||||||
|
/* This is a simple example showing how to send mime mail using libcurl's SMTP
|
||||||
|
* capabilities. For an example of using the multi interface please see
|
||||||
|
* smtp-multi.c.
|
||||||
|
*
|
||||||
|
* Note that this example requires libcurl 7.56.0 or above.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define FROM "<sender@example.org>"
|
||||||
|
#define TO "<addressee@example.net>"
|
||||||
|
#define CC "<info@example.org>"
|
||||||
|
|
||||||
|
static const char *headers_text[] = {
|
||||||
|
"Date: Tue, 22 Aug 2017 14:08:43 +0100",
|
||||||
|
"To: " TO,
|
||||||
|
"From: " FROM "(Example User)",
|
||||||
|
"Cc: " CC "(Another example User)",
|
||||||
|
"Message-ID: <dcd7cb36-11db-487a-9f3a-e652a9458efd@"
|
||||||
|
"rfcpedant.example.org>",
|
||||||
|
"Subject: example sending a MIME-formatted message",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char inline_text[] =
|
||||||
|
"This is the inline text message of the e-mail.\r\n"
|
||||||
|
"\r\n"
|
||||||
|
" It could be a lot of lines that would be displayed in an e-mail\r\n"
|
||||||
|
"viewer that is not able to handle HTML.\r\n";
|
||||||
|
|
||||||
|
static const char inline_html[] =
|
||||||
|
"<html><body>\r\n"
|
||||||
|
"<p>This is the inline <b>HTML</b> message of the e-mail.</p>"
|
||||||
|
"<br />\r\n"
|
||||||
|
"<p>It could be a lot of HTML data that would be displayed by "
|
||||||
|
"e-mail viewers able to handle HTML.</p>"
|
||||||
|
"</body></html>\r\n";
|
||||||
|
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
CURL *curl;
|
||||||
|
CURLcode res = CURLE_OK;
|
||||||
|
struct curl_slist *headers = NULL;
|
||||||
|
struct curl_slist *recipients = NULL;
|
||||||
|
struct curl_slist *slist = NULL;
|
||||||
|
curl_mime *mime;
|
||||||
|
curl_mime *alt;
|
||||||
|
curl_mimepart *part;
|
||||||
|
const char **cpp;
|
||||||
|
|
||||||
|
curl = curl_easy_init();
|
||||||
|
if(curl) {
|
||||||
|
/* This is the URL for your mailserver */
|
||||||
|
curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com");
|
||||||
|
|
||||||
|
/* Note that this option isn't strictly required, omitting it will result
|
||||||
|
* in libcurl sending the MAIL FROM command with empty sender data. All
|
||||||
|
* autoresponses should have an empty reverse-path, and should be directed
|
||||||
|
* to the address in the reverse-path which triggered them. Otherwise,
|
||||||
|
* they could cause an endless loop. See RFC 5321 Section 4.5.5 for more
|
||||||
|
* details.
|
||||||
|
*/
|
||||||
|
curl_easy_setopt(curl, CURLOPT_MAIL_FROM, FROM);
|
||||||
|
|
||||||
|
/* Add two recipients, in this particular case they correspond to the
|
||||||
|
* To: and Cc: addressees in the header, but they could be any kind of
|
||||||
|
* recipient. */
|
||||||
|
recipients = curl_slist_append(recipients, TO);
|
||||||
|
recipients = curl_slist_append(recipients, CC);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
|
||||||
|
|
||||||
|
/* Build and set the message header list. */
|
||||||
|
for(cpp = headers_text; *cpp; cpp++)
|
||||||
|
headers = curl_slist_append(headers, *cpp);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
|
||||||
|
|
||||||
|
/* Build the mime message. */
|
||||||
|
mime = curl_mime_init(curl);
|
||||||
|
|
||||||
|
/* The inline part is an alterative proposing the html and the text
|
||||||
|
versions of the e-mail. */
|
||||||
|
alt = curl_mime_init(curl);
|
||||||
|
|
||||||
|
/* HTML message. */
|
||||||
|
part = curl_mime_addpart(alt);
|
||||||
|
curl_mime_data(part, inline_html, -1);
|
||||||
|
curl_mime_type(part, "text/html");
|
||||||
|
|
||||||
|
/* Text message. */
|
||||||
|
part = curl_mime_addpart(alt);
|
||||||
|
curl_mime_data(part, inline_text, -1);
|
||||||
|
|
||||||
|
/* Create the inline part. */
|
||||||
|
part = curl_mime_addpart(mime);
|
||||||
|
curl_mime_subparts(part, alt);
|
||||||
|
curl_mime_type(part, "multipart/alternative");
|
||||||
|
slist = curl_slist_append(NULL, "Content-Disposition: inline");
|
||||||
|
curl_mime_headers(part, slist, 1);
|
||||||
|
|
||||||
|
/* Add the current source program as an attachment. */
|
||||||
|
part = curl_mime_addpart(mime);
|
||||||
|
curl_mime_filedata(part, "smtp-mime.c");
|
||||||
|
curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime);
|
||||||
|
|
||||||
|
/* Send the message */
|
||||||
|
res = curl_easy_perform(curl);
|
||||||
|
|
||||||
|
/* Check for errors */
|
||||||
|
if(res != CURLE_OK)
|
||||||
|
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||||
|
curl_easy_strerror(res));
|
||||||
|
|
||||||
|
/* Free lists. */
|
||||||
|
curl_slist_free_all(recipients);
|
||||||
|
curl_slist_free_all(headers);
|
||||||
|
|
||||||
|
/* curl won't send the QUIT command until you call cleanup, so you should
|
||||||
|
* be able to re-use this connection for additional messages (setting
|
||||||
|
* CURLOPT_MAIL_FROM and CURLOPT_MAIL_RCPT as required, and calling
|
||||||
|
* curl_easy_perform() again. It may not be a good idea to keep the
|
||||||
|
* connection open for a very long time though (more than a few minutes
|
||||||
|
* may result in the server timing out the connection), and you do want to
|
||||||
|
* clean up in the end.
|
||||||
|
*/
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (int)res;
|
||||||
|
}
|
@ -18,3 +18,6 @@
|
|||||||
1510
|
1510
|
||||||
# Pipelining test that is causing false positives a little too often
|
# Pipelining test that is causing false positives a little too often
|
||||||
1903
|
1903
|
||||||
|
# Entry point order should currently not be checked: mime API requires a
|
||||||
|
# SONAME change.
|
||||||
|
1135
|
||||||
|
@ -71,13 +71,14 @@ test545 test546 test547 test548 test549 test550 test551 test552 test553 \
|
|||||||
test554 test555 test556 test557 test558 test559 test560 test561 test562 \
|
test554 test555 test556 test557 test558 test559 test560 test561 test562 \
|
||||||
test563 test564 test565 test566 test567 test568 test569 test570 test571 \
|
test563 test564 test565 test566 test567 test568 test569 test570 test571 \
|
||||||
test572 test573 test574 test575 test576 test578 test579 test580 \
|
test572 test573 test574 test575 test576 test578 test579 test580 \
|
||||||
test581 test582 test583 test584 test585 test586 test587 test588 \
|
test581 test582 test583 test584 test585 test586 test587 test588 test589 \
|
||||||
test590 test591 test592 test593 test594 test595 test596 test597 test598 \
|
test590 test591 test592 test593 test594 test595 test596 test597 test598 \
|
||||||
test599 test600 test601 test602 test603 test604 test605 test606 test607 \
|
test599 test600 test601 test602 test603 test604 test605 test606 test607 \
|
||||||
test608 test609 test610 test611 test612 test613 test614 test615 test616 \
|
test608 test609 test610 test611 test612 test613 test614 test615 test616 \
|
||||||
test617 test618 test619 test620 test621 test622 test623 test624 test625 \
|
test617 test618 test619 test620 test621 test622 test623 test624 test625 \
|
||||||
test626 test627 test628 test629 test630 test631 test632 test633 test634 \
|
test626 test627 test628 test629 test630 test631 test632 test633 test634 \
|
||||||
test635 test636 test637 test638 test639 test640 test641 test642 \
|
test635 test636 test637 test638 test639 test640 test641 test642 \
|
||||||
|
test643 test644 test645 test646 test647 \
|
||||||
\
|
\
|
||||||
test700 test701 test702 test703 test704 test705 test706 test707 test708 \
|
test700 test701 test702 test703 test704 test705 test706 test707 test708 \
|
||||||
test709 test710 test711 test712 test713 test714 test715 \
|
test709 test710 test711 test712 test713 test714 test715 \
|
||||||
|
@ -79,7 +79,6 @@ User-Agent: curl/7.18.2 (i686-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.7a ipv6 z
|
|||||||
Host: %HOSTIP:%HTTPPORT
|
Host: %HOSTIP:%HTTPPORT
|
||||||
Accept: */*
|
Accept: */*
|
||||||
Content-Length: 410
|
Content-Length: 410
|
||||||
Expect: 100-continue
|
|
||||||
Content-Type: multipart/form-data; boundary=----------------------------9ef8d6205763
|
Content-Type: multipart/form-data; boundary=----------------------------9ef8d6205763
|
||||||
|
|
||||||
------------------------------9ef8d6205763
|
------------------------------9ef8d6205763
|
||||||
@ -104,7 +103,6 @@ User-Agent: curl/7.18.2 (i686-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.7a ipv6 z
|
|||||||
Host: %HOSTIP:%HTTPPORT
|
Host: %HOSTIP:%HTTPPORT
|
||||||
Accept: */*
|
Accept: */*
|
||||||
Content-Length: 410
|
Content-Length: 410
|
||||||
Expect: 100-continue
|
|
||||||
Content-Type: multipart/form-data; boundary=----------------------------9ef8d6205763
|
Content-Type: multipart/form-data; boundary=----------------------------9ef8d6205763
|
||||||
|
|
||||||
------------------------------9ef8d6205763
|
------------------------------9ef8d6205763
|
||||||
|
@ -47,8 +47,7 @@ POST /we/want/1133 HTTP/1.1
|
|||||||
User-Agent: curl/7.10.4 (i686-pc-linux-gnu) libcurl/7.10.4 OpenSSL/0.9.7a ipv6 zlib/1.1.3
|
User-Agent: curl/7.10.4 (i686-pc-linux-gnu) libcurl/7.10.4 OpenSSL/0.9.7a ipv6 zlib/1.1.3
|
||||||
Host: %HOSTIP:%HTTPPORT
|
Host: %HOSTIP:%HTTPPORT
|
||||||
Accept: */*
|
Accept: */*
|
||||||
Content-Length: 967
|
Content-Length: 969
|
||||||
Expect: 100-continue
|
|
||||||
Content-Type: multipart/form-data; boundary=----------------------------24e78000bd32
|
Content-Type: multipart/form-data; boundary=----------------------------24e78000bd32
|
||||||
|
|
||||||
------------------------------24e78000bd32
|
------------------------------24e78000bd32
|
||||||
@ -89,6 +88,7 @@ This is a bar foo
|
|||||||
bar
|
bar
|
||||||
foo
|
foo
|
||||||
|
|
||||||
|
|
||||||
------------------------------24e78000bd32--
|
------------------------------24e78000bd32--
|
||||||
</protocol>
|
</protocol>
|
||||||
</verify>
|
</verify>
|
||||||
|
@ -47,8 +47,7 @@ POST /we/want/1315 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
|
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
|
Host: %HOSTIP:%HTTPPORT
|
||||||
Accept: */*
|
Accept: */*
|
||||||
Content-Length: 795
|
Content-Length: 797
|
||||||
Expect: 100-continue
|
|
||||||
Content-Type: multipart/form-data; boundary=----------------------------9ef8d6205763
|
Content-Type: multipart/form-data; boundary=----------------------------9ef8d6205763
|
||||||
|
|
||||||
------------------------------9ef8d6205763
|
------------------------------9ef8d6205763
|
||||||
@ -77,6 +76,7 @@ Content-Type: text/plain
|
|||||||
dummy data
|
dummy data
|
||||||
|
|
||||||
------------------------------aaaaaaaaaaaa--
|
------------------------------aaaaaaaaaaaa--
|
||||||
|
|
||||||
------------------------------9ef8d6205763--
|
------------------------------9ef8d6205763--
|
||||||
</protocol>
|
</protocol>
|
||||||
</verify>
|
</verify>
|
||||||
|
@ -33,7 +33,7 @@ http
|
|||||||
SSL_CERT_FILE=
|
SSL_CERT_FILE=
|
||||||
</setenv>
|
</setenv>
|
||||||
<command>
|
<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>
|
</command>
|
||||||
# We create this file before the command is invoked!
|
# We create this file before the command is invoked!
|
||||||
<file name="log/test1404.txt">
|
<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
|
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
|
Host: %HOSTIP:%HTTPPORT
|
||||||
Accept: */*
|
Accept: */*
|
||||||
Content-Length: 795
|
Content-Length: 849
|
||||||
Expect: 100-continue
|
|
||||||
Content-Type: multipart/form-data; boundary=----------------------------9ef8d6205763
|
Content-Type: multipart/form-data; boundary=----------------------------9ef8d6205763
|
||||||
|
|
||||||
------------------------------9ef8d6205763
|
------------------------------9ef8d6205763
|
||||||
@ -77,10 +76,13 @@ dummy data
|
|||||||
------------------------------9ef8d6205763
|
------------------------------9ef8d6205763
|
||||||
Content-Disposition: attachment; filename="test1404.txt"
|
Content-Disposition: attachment; filename="test1404.txt"
|
||||||
Content-Type: text/plain
|
Content-Type: text/plain
|
||||||
|
X-testheader-1: header 1
|
||||||
|
X-testheader-2: header 2
|
||||||
|
|
||||||
dummy data
|
dummy data
|
||||||
|
|
||||||
------------------------------aaaaaaaaaaaa--
|
------------------------------aaaaaaaaaaaa--
|
||||||
|
|
||||||
------------------------------9ef8d6205763--
|
------------------------------9ef8d6205763--
|
||||||
</protocol>
|
</protocol>
|
||||||
<stripfile>
|
<stripfile>
|
||||||
@ -103,30 +105,41 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
CURLcode ret;
|
CURLcode ret;
|
||||||
CURL *hnd;
|
CURL *hnd;
|
||||||
struct curl_httppost *post1;
|
curl_mime *mime1;
|
||||||
struct curl_httppost *postend;
|
curl_mimepart *part1;
|
||||||
|
curl_mime *mime2;
|
||||||
|
curl_mimepart *part2;
|
||||||
|
struct curl_slist *slist1;
|
||||||
|
|
||||||
post1 = NULL;
|
mime1 = NULL;
|
||||||
postend = NULL;
|
mime2 = NULL;
|
||||||
curl_formadd(&post1, &postend,
|
slist1 = NULL;
|
||||||
CURLFORM_COPYNAME, "name",
|
slist1 = curl_slist_append(slist1, "X-testheader-1: header 1");
|
||||||
CURLFORM_COPYCONTENTS, "value",
|
slist1 = curl_slist_append(slist1, "X-testheader-2: header 2");
|
||||||
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);
|
|
||||||
|
|
||||||
hnd = curl_easy_init();
|
hnd = curl_easy_init();
|
||||||
curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
|
curl_easy_setopt(hnd, CURLOPT_BUFFERSIZE, 102400L);
|
||||||
curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/1404");
|
curl_easy_setopt(hnd, CURLOPT_URL, "http://%HOSTIP:%HTTPPORT/we/want/1404");
|
||||||
curl_easy_setopt(hnd, CURLOPT_HEADER, 1L);
|
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_USERAGENT, "stripped");
|
||||||
curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
|
curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
|
||||||
curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
|
curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
|
||||||
@ -156,8 +169,12 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
curl_easy_cleanup(hnd);
|
curl_easy_cleanup(hnd);
|
||||||
hnd = NULL;
|
hnd = NULL;
|
||||||
curl_formfree(post1);
|
curl_mime_free(mime1);
|
||||||
post1 = NULL;
|
mime1 = NULL;
|
||||||
|
curl_mime_free(mime2);
|
||||||
|
mime2 = NULL;
|
||||||
|
curl_slist_free_all(slist1);
|
||||||
|
slist1 = NULL;
|
||||||
|
|
||||||
return (int)ret;
|
return (int)ret;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,6 @@ User-Agent: curl/7.11.2-CVS (i686-pc-linux-gnu) libcurl/7.11.2-CVS OpenSSL/0.9.6
|
|||||||
Host: %HOSTIP:%HTTPPORT
|
Host: %HOSTIP:%HTTPPORT
|
||||||
Accept: */*
|
Accept: */*
|
||||||
Content-Length: 145
|
Content-Length: 145
|
||||||
Expect: 100-continue
|
|
||||||
Content-Type: multipart/form-data; boundary=----------------------------4f12fcdaa3bc
|
Content-Type: multipart/form-data; boundary=----------------------------4f12fcdaa3bc
|
||||||
|
|
||||||
------------------------------4f12fcdaa3bc
|
------------------------------4f12fcdaa3bc
|
||||||
|
@ -54,7 +54,6 @@ User-Agent: curl/7.11.2-CVS (i686-pc-linux-gnu) libcurl/7.11.2-CVS OpenSSL/0.9.6
|
|||||||
Host: %HOSTIP:%HTTPPORT
|
Host: %HOSTIP:%HTTPPORT
|
||||||
Accept: */*
|
Accept: */*
|
||||||
Content-Length: 304
|
Content-Length: 304
|
||||||
Expect: 100-continue
|
|
||||||
Content-Type: multipart/form-data; boundary=----------------------------c2d1767eb6ac
|
Content-Type: multipart/form-data; boundary=----------------------------c2d1767eb6ac
|
||||||
|
|
||||||
------------------------------c2d1767eb6ac
|
------------------------------c2d1767eb6ac
|
||||||
|
@ -46,7 +46,6 @@ User-Agent: curl/7.12.0-CVS (i686-pc-linux-gnu) libcurl/7.12.0-CVS OpenSSL/0.9.6
|
|||||||
Host: %HOSTIP:%HTTPPORT
|
Host: %HOSTIP:%HTTPPORT
|
||||||
Accept: */*
|
Accept: */*
|
||||||
Content-Length: 223
|
Content-Length: 223
|
||||||
Expect: 100-continue
|
|
||||||
Content-Type: multipart/form-data; boundary=----------------------------b0b3d6d23991
|
Content-Type: multipart/form-data; boundary=----------------------------b0b3d6d23991
|
||||||
|
|
||||||
------------------------------b0b3d6d23991
|
------------------------------b0b3d6d23991
|
||||||
|
@ -54,7 +54,6 @@ User-Agent: curl/7.12.1-CVS (i686-pc-linux-gnu) libcurl/7.12.1-CVS OpenSSL/0.9.6
|
|||||||
Host: %HOSTIP:%HTTPPORT
|
Host: %HOSTIP:%HTTPPORT
|
||||||
Accept: */*
|
Accept: */*
|
||||||
Content-Length: 360
|
Content-Length: 360
|
||||||
Expect: 100-continue
|
|
||||||
Content-Type: multipart/form-data; boundary=----------------------------5dbea401cd8c
|
Content-Type: multipart/form-data; boundary=----------------------------5dbea401cd8c
|
||||||
|
|
||||||
------------------------------5dbea401cd8c
|
------------------------------5dbea401cd8c
|
||||||
|
@ -43,8 +43,7 @@ POST /we/want/186 HTTP/1.1
|
|||||||
User-Agent: curl/7.12.2-CVS (i686-pc-linux-gnu) libcurl/7.12.2-CVS OpenSSL/0.9.7d zlib/1.2.1.1 c-ares/1.2.0 libidn/0.5.2
|
User-Agent: curl/7.12.2-CVS (i686-pc-linux-gnu) libcurl/7.12.2-CVS OpenSSL/0.9.7d zlib/1.2.1.1 c-ares/1.2.0 libidn/0.5.2
|
||||||
Host: %HOSTIP:%HTTPPORT
|
Host: %HOSTIP:%HTTPPORT
|
||||||
Accept: */*
|
Accept: */*
|
||||||
Content-Length: 321
|
Content-Length: 320
|
||||||
Expect: 100-continue
|
|
||||||
Content-Type: multipart/form-data; boundary=----------------------------212d9006ceb5
|
Content-Type: multipart/form-data; boundary=----------------------------212d9006ceb5
|
||||||
|
|
||||||
------------------------------212d9006ceb5
|
------------------------------212d9006ceb5
|
||||||
@ -56,7 +55,7 @@ daniel
|
|||||||
Content-Disposition: form-data; name="html"
|
Content-Disposition: form-data; name="html"
|
||||||
Content-Type: text/html;charset=verymoo
|
Content-Type: text/html;charset=verymoo
|
||||||
|
|
||||||
<body>hello</body>
|
<body>hello</body>
|
||||||
------------------------------212d9006ceb5--
|
------------------------------212d9006ceb5--
|
||||||
</protocol>
|
</protocol>
|
||||||
</verify>
|
</verify>
|
||||||
|
@ -59,7 +59,7 @@ crypto
|
|||||||
HTTP POST multipart with Expect: header using proxy anyauth (Digest)
|
HTTP POST multipart with Expect: header using proxy anyauth (Digest)
|
||||||
</name>
|
</name>
|
||||||
<command>
|
<command>
|
||||||
-x http://%HOSTIP:%HTTPPORT http://remotehost:54321/we/want/259 -F name=daniel -F tool=curl -F file=@log/test259.txt -U uuuser:pppassword --proxy-anyauth
|
-x http://%HOSTIP:%HTTPPORT http://remotehost:54321/we/want/259 -F name=daniel -F tool=curl -F file=@log/test259.txt -U uuuser:pppassword --proxy-anyauth -H "Expect: 100-continue"
|
||||||
</command>
|
</command>
|
||||||
# We create this file before the command is invoked!
|
# We create this file before the command is invoked!
|
||||||
<file name="log/test259.txt">
|
<file name="log/test259.txt">
|
||||||
@ -80,8 +80,8 @@ Host: remotehost:54321
|
|||||||
User-Agent: curl/7.10.4 (i686-pc-linux-gnu) libcurl/7.10.4 OpenSSL/0.9.7a ipv6 zlib/1.1.3
|
User-Agent: curl/7.10.4 (i686-pc-linux-gnu) libcurl/7.10.4 OpenSSL/0.9.7a ipv6 zlib/1.1.3
|
||||||
Accept: */*
|
Accept: */*
|
||||||
Proxy-Connection: Keep-Alive
|
Proxy-Connection: Keep-Alive
|
||||||
Content-Length: 409
|
|
||||||
Expect: 100-continue
|
Expect: 100-continue
|
||||||
|
Content-Length: 409
|
||||||
Content-Type: multipart/form-data; boundary=----------------------------7c633d5c27ce
|
Content-Type: multipart/form-data; boundary=----------------------------7c633d5c27ce
|
||||||
|
|
||||||
------------------------------7c633d5c27ce
|
------------------------------7c633d5c27ce
|
||||||
@ -107,8 +107,8 @@ User-Agent: curl/7.10.4 (i686-pc-linux-gnu) libcurl/7.10.4 OpenSSL/0.9.7a ipv6 z
|
|||||||
Proxy-Authorization: Digest username="uuuser", realm="many secrets", nonce="911", uri="/we/want/259", response="b479994d13e60f3aa192a67c5892ddc5"
|
Proxy-Authorization: Digest username="uuuser", realm="many secrets", nonce="911", uri="/we/want/259", response="b479994d13e60f3aa192a67c5892ddc5"
|
||||||
Accept: */*
|
Accept: */*
|
||||||
Proxy-Connection: Keep-Alive
|
Proxy-Connection: Keep-Alive
|
||||||
Content-Length: 409
|
|
||||||
Expect: 100-continue
|
Expect: 100-continue
|
||||||
|
Content-Length: 409
|
||||||
Content-Type: multipart/form-data; boundary=----------------------------7c633d5c27ce
|
Content-Type: multipart/form-data; boundary=----------------------------7c633d5c27ce
|
||||||
|
|
||||||
------------------------------7c633d5c27ce
|
------------------------------7c633d5c27ce
|
||||||
|
@ -45,12 +45,11 @@ POST /want/277 HTTP/1.1
|
|||||||
User-Agent: curl/7.10.4 (i686-pc-linux-gnu) libcurl/7.10.4 OpenSSL/0.9.7a ipv6 zlib/1.1.3
|
User-Agent: curl/7.10.4 (i686-pc-linux-gnu) libcurl/7.10.4 OpenSSL/0.9.7a ipv6 zlib/1.1.3
|
||||||
Host: %HOSTIP:%HTTPPORT
|
Host: %HOSTIP:%HTTPPORT
|
||||||
Accept: */*
|
Accept: */*
|
||||||
Content-Length: 145
|
Content-Length: 146
|
||||||
Expect: 100-continue
|
|
||||||
Content-Type: text/info; boundary=------------------------
|
Content-Type: text/info; boundary=------------------------
|
||||||
|
|
||||||
--------------------------
|
--------------------------
|
||||||
Content-Disposition: form-data; name="name"
|
Content-Disposition: attachment; name="name"
|
||||||
|
|
||||||
daniel
|
daniel
|
||||||
----------------------------
|
----------------------------
|
||||||
|
@ -69,7 +69,6 @@ POST /554 HTTP/1.1
|
|||||||
Host: %HOSTIP:%HTTPPORT
|
Host: %HOSTIP:%HTTPPORT
|
||||||
Accept: */*
|
Accept: */*
|
||||||
Content-Length: 718
|
Content-Length: 718
|
||||||
Expect: 100-continue
|
|
||||||
Content-Type: multipart/form-data; boundary=----------------------------
|
Content-Type: multipart/form-data; boundary=----------------------------
|
||||||
|
|
||||||
------------------------------
|
------------------------------
|
||||||
@ -100,7 +99,6 @@ POST /554 HTTP/1.1
|
|||||||
Host: %HOSTIP:%HTTPPORT
|
Host: %HOSTIP:%HTTPPORT
|
||||||
Accept: */*
|
Accept: */*
|
||||||
Content-Length: 732
|
Content-Length: 732
|
||||||
Expect: 100-continue
|
|
||||||
Content-Type: multipart/form-data; boundary=----------------------------
|
Content-Type: multipart/form-data; boundary=----------------------------
|
||||||
|
|
||||||
------------------------------
|
------------------------------
|
||||||
|
@ -43,7 +43,6 @@ POST /587 HTTP/1.1
|
|||||||
Host: %HOSTIP:%HTTPPORT
|
Host: %HOSTIP:%HTTPPORT
|
||||||
Accept: */*
|
Accept: */*
|
||||||
Content-Length: 718
|
Content-Length: 718
|
||||||
Expect: 100-continue
|
|
||||||
Content-Type: multipart/form-data; boundary=----------------------------
|
Content-Type: multipart/form-data; boundary=----------------------------
|
||||||
|
|
||||||
------------------------------
|
------------------------------
|
||||||
|
55
tests/data/test589
Normal file
55
tests/data/test589
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
<testcase>
|
||||||
|
<info>
|
||||||
|
<keywords>
|
||||||
|
HTTP
|
||||||
|
HTTP POST
|
||||||
|
HTTP MIME
|
||||||
|
</keywords>
|
||||||
|
</info>
|
||||||
|
|
||||||
|
#
|
||||||
|
# Server-side
|
||||||
|
<reply>
|
||||||
|
<data>
|
||||||
|
HTTP/1.1 200 OK swsclose
|
||||||
|
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||||
|
Server: test-server/fake
|
||||||
|
Content-Length: 3
|
||||||
|
|
||||||
|
OK
|
||||||
|
</data>
|
||||||
|
</reply>
|
||||||
|
|
||||||
|
# Client-side
|
||||||
|
<client>
|
||||||
|
<server>
|
||||||
|
http
|
||||||
|
</server>
|
||||||
|
# tool is what to use instead of 'curl'
|
||||||
|
<tool>
|
||||||
|
lib589
|
||||||
|
</tool>
|
||||||
|
|
||||||
|
<name>
|
||||||
|
make a HTTP MIME POST set to NULL
|
||||||
|
</name>
|
||||||
|
<command>
|
||||||
|
http://%HOSTIP:%HTTPPORT/589
|
||||||
|
</command>
|
||||||
|
</client>
|
||||||
|
|
||||||
|
#
|
||||||
|
# Verify data after the test has been "shot"
|
||||||
|
<verify>
|
||||||
|
<strip>
|
||||||
|
^User-Agent:.*
|
||||||
|
</strip>
|
||||||
|
<protocol>
|
||||||
|
POST /589 HTTP/1.1
|
||||||
|
Host: %HOSTIP:%HTTPPORT
|
||||||
|
Accept: */*
|
||||||
|
Content-Length: 0
|
||||||
|
|
||||||
|
</protocol>
|
||||||
|
</verify>
|
||||||
|
</testcase>
|
131
tests/data/test643
Normal file
131
tests/data/test643
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
<testcase>
|
||||||
|
<info>
|
||||||
|
<keywords>
|
||||||
|
HTTP
|
||||||
|
HTTP POST
|
||||||
|
HTTP MIME POST
|
||||||
|
</keywords>
|
||||||
|
</info>
|
||||||
|
|
||||||
|
#
|
||||||
|
# Server-side
|
||||||
|
<reply>
|
||||||
|
<data>
|
||||||
|
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
|
||||||
|
</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
|
||||||
|
<client>
|
||||||
|
<server>
|
||||||
|
http
|
||||||
|
</server>
|
||||||
|
# tool is what to use instead of 'curl'
|
||||||
|
<tool>
|
||||||
|
lib643
|
||||||
|
</tool>
|
||||||
|
|
||||||
|
<name>
|
||||||
|
HTTP multi-part mimepost using read callback for the file part
|
||||||
|
</name>
|
||||||
|
<command>
|
||||||
|
http://%HOSTIP:%HTTPPORT/643
|
||||||
|
</command>
|
||||||
|
</client>
|
||||||
|
|
||||||
|
#
|
||||||
|
# Verify data after the test has been "shot"
|
||||||
|
<verify>
|
||||||
|
<strippart>
|
||||||
|
s/^--------------------------[a-z0-9]*/------------------------------/
|
||||||
|
s/boundary=------------------------[a-z0-9]*/boundary=----------------------------/
|
||||||
|
</strippart>
|
||||||
|
# Note that the stripping above removes 12 bytes from every occurrence of the
|
||||||
|
# boundary string and since 5 of them are in the body contents, we see
|
||||||
|
# (5*12) == 60 bytes less
|
||||||
|
<protocol>
|
||||||
|
POST /643 HTTP/1.1
|
||||||
|
Host: %HOSTIP:%HTTPPORT
|
||||||
|
Accept: */*
|
||||||
|
Content-Length: 718
|
||||||
|
Content-Type: multipart/form-data; boundary=----------------------------
|
||||||
|
|
||||||
|
------------------------------
|
||||||
|
Content-Disposition: form-data; name="sendfile"; filename="postit2.c"
|
||||||
|
|
||||||
|
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
|
||||||
|
--------------------------------
|
||||||
|
POST /643 HTTP/1.1
|
||||||
|
Host: %HOSTIP:%HTTPPORT
|
||||||
|
Accept: */*
|
||||||
|
Content-Length: 732
|
||||||
|
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>
|
58
tests/data/test644
Normal file
58
tests/data/test644
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<testcase>
|
||||||
|
<info>
|
||||||
|
<keywords>
|
||||||
|
HTTP
|
||||||
|
HTTP POST
|
||||||
|
HTTP MIME POST
|
||||||
|
</keywords>
|
||||||
|
</info>
|
||||||
|
|
||||||
|
#
|
||||||
|
# Server-side
|
||||||
|
<reply>
|
||||||
|
<data>
|
||||||
|
</data>
|
||||||
|
</reply>
|
||||||
|
|
||||||
|
# Client-side
|
||||||
|
<client>
|
||||||
|
<server>
|
||||||
|
http
|
||||||
|
</server>
|
||||||
|
# tool is what to use instead of 'curl'
|
||||||
|
<tool>
|
||||||
|
lib644
|
||||||
|
</tool>
|
||||||
|
|
||||||
|
<name>
|
||||||
|
HTTP multi-part formpost with aborted read callback
|
||||||
|
</name>
|
||||||
|
<command>
|
||||||
|
http://%HOSTIP:%HTTPPORT/644
|
||||||
|
</command>
|
||||||
|
</client>
|
||||||
|
|
||||||
|
#
|
||||||
|
# Verify data after the test has been "shot"
|
||||||
|
<verify>
|
||||||
|
<strippart>
|
||||||
|
s/^--------------------------[a-z0-9]*/------------------------------/
|
||||||
|
s/boundary=------------------------[a-z0-9]*/boundary=----------------------------/
|
||||||
|
</strippart>
|
||||||
|
<protocol>
|
||||||
|
POST /644 HTTP/1.1
|
||||||
|
Host: %HOSTIP:%HTTPPORT
|
||||||
|
Accept: */*
|
||||||
|
Content-Length: 718
|
||||||
|
Content-Type: multipart/form-data; boundary=----------------------------
|
||||||
|
|
||||||
|
------------------------------
|
||||||
|
Content-Disposition: form-data; name="sendfile"; filename="postit2.c"
|
||||||
|
|
||||||
|
</protocol>
|
||||||
|
# CURLE_ABORTED_BY_CALLBACK (42)
|
||||||
|
<errorcode>
|
||||||
|
42
|
||||||
|
</errorcode>
|
||||||
|
</verify>
|
||||||
|
</testcase>
|
141
tests/data/test645
Normal file
141
tests/data/test645
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
<testcase>
|
||||||
|
<info>
|
||||||
|
<keywords>
|
||||||
|
HTTP
|
||||||
|
HTTP POST
|
||||||
|
HTTP MIME POST
|
||||||
|
</keywords>
|
||||||
|
</info>
|
||||||
|
|
||||||
|
#
|
||||||
|
# Server-side
|
||||||
|
<reply>
|
||||||
|
<data>
|
||||||
|
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
|
||||||
|
</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
|
||||||
|
<client>
|
||||||
|
<server>
|
||||||
|
http
|
||||||
|
</server>
|
||||||
|
# tool is what to use instead of 'curl'
|
||||||
|
<tool>
|
||||||
|
lib645
|
||||||
|
</tool>
|
||||||
|
|
||||||
|
<name>
|
||||||
|
HTTP multi-part chunked mimepost using read callback for the file part
|
||||||
|
</name>
|
||||||
|
<command>
|
||||||
|
http://%HOSTIP:%HTTPPORT/645
|
||||||
|
</command>
|
||||||
|
</client>
|
||||||
|
|
||||||
|
#
|
||||||
|
# Verify data after the test has been "shot"
|
||||||
|
<verify>
|
||||||
|
<strippart>
|
||||||
|
s/^--------------------------[a-z0-9]*/------------------------------/
|
||||||
|
s/boundary=------------------------[a-z0-9]*/boundary=----------------------------/
|
||||||
|
</strippart>
|
||||||
|
# Note that the stripping above removes 12 bytes from every occurrence of the
|
||||||
|
# boundary string and since 5 of them are in the body contents, we see
|
||||||
|
# (5*12) == 60 bytes less
|
||||||
|
<protocol>
|
||||||
|
POST /645 HTTP/1.1
|
||||||
|
Host: %HOSTIP:%HTTPPORT
|
||||||
|
Accept: */*
|
||||||
|
Transfer-Encoding: chunked
|
||||||
|
Content-Type: multipart/form-data; boundary=----------------------------
|
||||||
|
Expect: 100-continue
|
||||||
|
|
||||||
|
2ce
|
||||||
|
------------------------------
|
||||||
|
Content-Disposition: form-data; name="sendfile"; filename="postit2.c"
|
||||||
|
|
||||||
|
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
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
0
|
||||||
|
|
||||||
|
POST /645 HTTP/1.1
|
||||||
|
Host: %HOSTIP:%HTTPPORT
|
||||||
|
Accept: */*
|
||||||
|
Transfer-Encoding: chunked
|
||||||
|
Content-Type: multipart/form-data; boundary=----------------------------
|
||||||
|
Expect: 100-continue
|
||||||
|
|
||||||
|
2dc
|
||||||
|
------------------------------
|
||||||
|
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
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
0
|
||||||
|
|
||||||
|
</protocol>
|
||||||
|
</verify>
|
||||||
|
</testcase>
|
98
tests/data/test646
Normal file
98
tests/data/test646
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
<testcase>
|
||||||
|
<info>
|
||||||
|
<keywords>
|
||||||
|
SMTP
|
||||||
|
MULTIPART
|
||||||
|
</keywords>
|
||||||
|
</info>
|
||||||
|
|
||||||
|
#
|
||||||
|
# Server-side
|
||||||
|
<reply>
|
||||||
|
</reply>
|
||||||
|
|
||||||
|
#
|
||||||
|
# Client-side
|
||||||
|
<client>
|
||||||
|
<server>
|
||||||
|
smtp
|
||||||
|
</server>
|
||||||
|
<name>
|
||||||
|
SMTP multipart using mime API
|
||||||
|
</name>
|
||||||
|
<stdin>
|
||||||
|
From: different
|
||||||
|
To: another
|
||||||
|
|
||||||
|
body
|
||||||
|
</stdin>
|
||||||
|
<command>
|
||||||
|
smtp://%HOSTIP:%SMTPPORT/646 --mail-rcpt recipient@example.com --mail-from sender@example.com -F "=(;type=multipart/alternative" -F "= <body>This is the html version</body>;headers=X-test1: this is a header;type=text/html;headers=X-test2: this is another header " -F "=This is the plain text version;headers=@log/headers646" -F "=)" -F "=@log/test646.txt;headers=<log/headers646" -H "From: different" -H "To: another" -H "Reply-To: <followup@example.com>"
|
||||||
|
</command>
|
||||||
|
<file1 name="log/test646.txt">
|
||||||
|
This is an attached file.
|
||||||
|
|
||||||
|
It may contain any type of data.
|
||||||
|
</file1>
|
||||||
|
<file2 name="log/headers646">
|
||||||
|
# This line is a comment
|
||||||
|
X-fileheader1: This is a header from a file
|
||||||
|
|
||||||
|
# This line is another comment. It precedes a folded header.
|
||||||
|
X-fileheader2: This is
#a
|
||||||
|
folded header
|
||||||
|
</file2>
|
||||||
|
</client>
|
||||||
|
|
||||||
|
#
|
||||||
|
# Verify data after the test has been "shot"
|
||||||
|
<verify>
|
||||||
|
<strippart>
|
||||||
|
s/^--------------------------[a-z0-9]*/------------------------------/
|
||||||
|
s/boundary=------------------------[a-z0-9]*/boundary=----------------------------/
|
||||||
|
</strippart>
|
||||||
|
<protocol>
|
||||||
|
EHLO 646
|
||||||
|
MAIL FROM:<sender@example.com>
|
||||||
|
RCPT TO:<recipient@example.com>
|
||||||
|
DATA
|
||||||
|
QUIT
|
||||||
|
</protocol>
|
||||||
|
<upload>
|
||||||
|
Content-Type: multipart/mixed; boundary=----------------------------
|
||||||
|
Mime-Version: 1.0
|
||||||
|
From: different
|
||||||
|
To: another
|
||||||
|
Reply-To: <followup@example.com>
|
||||||
|
|
||||||
|
------------------------------
|
||||||
|
Content-Type: multipart/alternative; boundary=----------------------------
|
||||||
|
|
||||||
|
------------------------------
|
||||||
|
Content-Type: text/html
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
X-test1: this is a header
|
||||||
|
X-test2: this is another header
|
||||||
|
|
||||||
|
<body>This is the html version</body>
|
||||||
|
------------------------------
|
||||||
|
X-fileheader1: This is a header from a file
|
||||||
|
X-fileheader2: This is #a folded header
|
||||||
|
|
||||||
|
This is the plain text version
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
------------------------------
|
||||||
|
Content-Disposition: attachment; filename="test646.txt"
|
||||||
|
X-fileheader1: This is a header from a file
|
||||||
|
X-fileheader2: This is #a folded header
|
||||||
|
|
||||||
|
This is an attached file.
|
||||||
|
|
||||||
|
It may contain any type of data.
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
.
|
||||||
|
</upload>
|
||||||
|
</verify>
|
||||||
|
</testcase>
|
79
tests/data/test647
Normal file
79
tests/data/test647
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
<testcase>
|
||||||
|
<info>
|
||||||
|
<keywords>
|
||||||
|
IMAP
|
||||||
|
APPEND
|
||||||
|
MULTIPART
|
||||||
|
</keywords>
|
||||||
|
</info>
|
||||||
|
|
||||||
|
#
|
||||||
|
# Server-side
|
||||||
|
<reply>
|
||||||
|
</reply>
|
||||||
|
|
||||||
|
#
|
||||||
|
# Client-side
|
||||||
|
<client>
|
||||||
|
<server>
|
||||||
|
imap
|
||||||
|
</server>
|
||||||
|
<name>
|
||||||
|
IMAP APPEND multipart using mime API
|
||||||
|
</name>
|
||||||
|
<command>
|
||||||
|
imap://%HOSTIP:%IMAPPORT/647 -F "=(;type=multipart/alternative" -F "= <body>This is the html version</body>;type=text/html" -F "=This is the plain text version" -F "=)" -F "=@log/test647.txt" -H "Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)" -H "From: Fred Foobar <foobar@example.com>" -H "To: joe@example.com" -H "Message-Id: <B27397-0100000@example.com>" -H "Subject: afternoon meeting" -u user:secret
|
||||||
|
</command>
|
||||||
|
<file name="log/test647.txt">
|
||||||
|
This is an attached file.
|
||||||
|
|
||||||
|
It may contain any type of data.
|
||||||
|
</file>
|
||||||
|
</client>
|
||||||
|
|
||||||
|
#
|
||||||
|
# Verify data after the test has been "shot"
|
||||||
|
<verify>
|
||||||
|
<strippart>
|
||||||
|
s/^--------------------------[a-z0-9]*/------------------------------/
|
||||||
|
s/boundary=------------------------[a-z0-9]*/boundary=----------------------------/
|
||||||
|
</strippart>
|
||||||
|
<protocol>
|
||||||
|
A001 CAPABILITY
|
||||||
|
A002 LOGIN user secret
|
||||||
|
A003 APPEND 647 (\Seen) {892}
|
||||||
|
A004 LOGOUT
|
||||||
|
</protocol>
|
||||||
|
<upload>
|
||||||
|
Content-Type: multipart/mixed; boundary=----------------------------
|
||||||
|
Mime-Version: 1.0
|
||||||
|
Date: Mon, 7 Feb 1994 21:52:25 -0800 (PST)
|
||||||
|
From: Fred Foobar <foobar@example.com>
|
||||||
|
To: joe@example.com
|
||||||
|
Message-Id: <B27397-0100000@example.com>
|
||||||
|
Subject: afternoon meeting
|
||||||
|
|
||||||
|
------------------------------
|
||||||
|
Content-Type: multipart/alternative; boundary=----------------------------
|
||||||
|
|
||||||
|
------------------------------
|
||||||
|
Content-Type: text/html
|
||||||
|
Content-Transfer-Encoding: 8bit
|
||||||
|
|
||||||
|
<body>This is the html version</body>
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
This is the plain text version
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
------------------------------
|
||||||
|
Content-Disposition: attachment; filename="test647.txt"
|
||||||
|
|
||||||
|
This is an attached file.
|
||||||
|
|
||||||
|
It may contain any type of data.
|
||||||
|
|
||||||
|
--------------------------------
|
||||||
|
</upload>
|
||||||
|
</verify>
|
||||||
|
</testcase>
|
@ -54,7 +54,6 @@ POST /we/want/71 HTTP/1.1
|
|||||||
Host: %HOSTIP:%HTTPPORT
|
Host: %HOSTIP:%HTTPPORT
|
||||||
Accept: */*
|
Accept: */*
|
||||||
Content-Length: 408
|
Content-Length: 408
|
||||||
Expect: 100-continue
|
|
||||||
Content-Type: multipart/form-data; boundary=----------------------------9ef8d6205763
|
Content-Type: multipart/form-data; boundary=----------------------------9ef8d6205763
|
||||||
|
|
||||||
------------------------------9ef8d6205763
|
------------------------------9ef8d6205763
|
||||||
|
@ -48,7 +48,6 @@ User-Agent: curl/7.10.4 (i686-pc-linux-gnu) libcurl/7.10.4 OpenSSL/0.9.7a ipv6 z
|
|||||||
Host: %HOSTIP:%HTTPPORT
|
Host: %HOSTIP:%HTTPPORT
|
||||||
Accept: */*
|
Accept: */*
|
||||||
Content-Length: 407
|
Content-Length: 407
|
||||||
Expect: 100-continue
|
|
||||||
Content-Type: multipart/form-data; boundary=----------------------------9ef8d6205763
|
Content-Type: multipart/form-data; boundary=----------------------------9ef8d6205763
|
||||||
|
|
||||||
------------------------------9ef8d6205763
|
------------------------------9ef8d6205763
|
||||||
|
@ -19,7 +19,8 @@ noinst_PROGRAMS = chkhostname libauthretry libntlmconnect \
|
|||||||
lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 lib557 lib558 \
|
lib547 lib548 lib549 lib552 lib553 lib554 lib555 lib556 lib557 lib558 \
|
||||||
lib559 lib560 lib562 lib564 lib565 lib566 lib567 lib568 lib569 lib570 \
|
lib559 lib560 lib562 lib564 lib565 lib566 lib567 lib568 lib569 lib570 \
|
||||||
lib571 lib572 lib573 lib574 lib575 lib576 lib578 lib579 lib582 \
|
lib571 lib572 lib573 lib574 lib575 lib576 lib578 lib579 lib582 \
|
||||||
lib583 lib585 lib586 lib587 lib590 lib591 lib597 lib598 lib599 \
|
lib583 lib585 lib586 lib587 lib589 lib590 lib591 lib597 lib598 lib599 \
|
||||||
|
lib643 lib644 lib645 \
|
||||||
lib1500 lib1501 lib1502 lib1503 lib1504 lib1505 lib1506 lib1507 lib1508 \
|
lib1500 lib1501 lib1502 lib1503 lib1504 lib1505 lib1506 lib1507 lib1508 \
|
||||||
lib1509 lib1510 lib1511 lib1512 lib1513 lib1514 lib1515 lib1517 \
|
lib1509 lib1510 lib1511 lib1512 lib1513 lib1514 lib1515 lib1517 \
|
||||||
lib1520 lib1521 \
|
lib1520 lib1521 \
|
||||||
@ -282,6 +283,9 @@ lib586_CPPFLAGS = $(AM_CPPFLAGS)
|
|||||||
lib587_SOURCES = lib554.c $(SUPPORTFILES)
|
lib587_SOURCES = lib554.c $(SUPPORTFILES)
|
||||||
lib587_CPPFLAGS = $(AM_CPPFLAGS) -DLIB587
|
lib587_CPPFLAGS = $(AM_CPPFLAGS) -DLIB587
|
||||||
|
|
||||||
|
lib589_SOURCES = lib589.c $(SUPPORTFILES)
|
||||||
|
lib589_CPPFLAGS = $(AM_CPPFLAGS)
|
||||||
|
|
||||||
lib590_SOURCES = lib590.c $(SUPPORTFILES)
|
lib590_SOURCES = lib590.c $(SUPPORTFILES)
|
||||||
lib590_CPPFLAGS = $(AM_CPPFLAGS)
|
lib590_CPPFLAGS = $(AM_CPPFLAGS)
|
||||||
|
|
||||||
@ -299,6 +303,15 @@ lib598_CPPFLAGS = $(AM_CPPFLAGS)
|
|||||||
lib599_SOURCES = lib599.c $(SUPPORTFILES)
|
lib599_SOURCES = lib599.c $(SUPPORTFILES)
|
||||||
lib599_CPPFLAGS = $(AM_CPPFLAGS)
|
lib599_CPPFLAGS = $(AM_CPPFLAGS)
|
||||||
|
|
||||||
|
lib643_SOURCES = lib643.c $(SUPPORTFILES)
|
||||||
|
lib643_CPPFLAGS = $(AM_CPPFLAGS)
|
||||||
|
|
||||||
|
lib644_SOURCES = lib643.c $(SUPPORTFILES)
|
||||||
|
lib644_CPPFLAGS = $(AM_CPPFLAGS) -DLIB644
|
||||||
|
|
||||||
|
lib645_SOURCES = lib643.c $(SUPPORTFILES)
|
||||||
|
lib645_CPPFLAGS = $(AM_CPPFLAGS) -DLIB645
|
||||||
|
|
||||||
lib1500_SOURCES = lib1500.c $(SUPPORTFILES) $(TESTUTIL)
|
lib1500_SOURCES = lib1500.c $(SUPPORTFILES) $(TESTUTIL)
|
||||||
lib1500_LDADD = $(TESTUTIL_LIBS)
|
lib1500_LDADD = $(TESTUTIL_LIBS)
|
||||||
lib1500_CPPFLAGS = $(AM_CPPFLAGS)
|
lib1500_CPPFLAGS = $(AM_CPPFLAGS)
|
||||||
|
59
tests/libtest/lib589.c
Normal file
59
tests/libtest/lib589.c
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* _ _ ____ _
|
||||||
|
* Project ___| | | | _ \| |
|
||||||
|
* / __| | | | |_) | |
|
||||||
|
* | (__| |_| | _ <| |___
|
||||||
|
* \___|\___/|_| \_\_____|
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998 - 2017, 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
|
||||||
|
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||||
|
*
|
||||||
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||||
|
* copies of the Software, and permit persons to whom the Software is
|
||||||
|
* furnished to do so, under the terms of the COPYING file.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
***************************************************************************/
|
||||||
|
#include "test.h"
|
||||||
|
|
||||||
|
#include "memdebug.h"
|
||||||
|
|
||||||
|
int test(char *URL)
|
||||||
|
{
|
||||||
|
CURL *curl;
|
||||||
|
CURLcode res=CURLE_OK;
|
||||||
|
|
||||||
|
if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
|
||||||
|
fprintf(stderr, "curl_global_init() failed\n");
|
||||||
|
return TEST_ERR_MAJOR_BAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
curl = curl_easy_init();
|
||||||
|
if(!curl) {
|
||||||
|
fprintf(stderr, "curl_easy_init() failed\n");
|
||||||
|
curl_global_cleanup();
|
||||||
|
return TEST_ERR_MAJOR_BAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* First set the URL that is about to receive our POST. */
|
||||||
|
test_setopt(curl, CURLOPT_URL, URL);
|
||||||
|
test_setopt(curl, CURLOPT_MIMEPOST, NULL);
|
||||||
|
test_setopt(curl, CURLOPT_VERBOSE, 1L); /* show verbose for debug */
|
||||||
|
test_setopt(curl, CURLOPT_HEADER, 1L); /* include header */
|
||||||
|
|
||||||
|
/* Now, we should be making a zero byte POST request */
|
||||||
|
res = curl_easy_perform(curl);
|
||||||
|
|
||||||
|
test_cleanup:
|
||||||
|
|
||||||
|
/* always cleanup */
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
|
curl_global_cleanup();
|
||||||
|
|
||||||
|
return (int)res;
|
||||||
|
}
|
270
tests/libtest/lib643.c
Normal file
270
tests/libtest/lib643.c
Normal file
@ -0,0 +1,270 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* _ _ ____ _
|
||||||
|
* Project ___| | | | _ \| |
|
||||||
|
* / __| | | | |_) | |
|
||||||
|
* | (__| |_| | _ <| |___
|
||||||
|
* \___|\___/|_| \_\_____|
|
||||||
|
*
|
||||||
|
* Copyright (C) 1998 - 2017, 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
|
||||||
|
* are also available at https://curl.haxx.se/docs/copyright.html.
|
||||||
|
*
|
||||||
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||||
|
* copies of the Software, and permit persons to whom the Software is
|
||||||
|
* furnished to do so, under the terms of the COPYING file.
|
||||||
|
*
|
||||||
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
* KIND, either express or implied.
|
||||||
|
*
|
||||||
|
***************************************************************************/
|
||||||
|
#include "test.h"
|
||||||
|
|
||||||
|
#include "memdebug.h"
|
||||||
|
|
||||||
|
static char data[]=
|
||||||
|
#ifdef CURL_DOES_CONVERSIONS
|
||||||
|
/* ASCII representation with escape sequences for non-ASCII platforms */
|
||||||
|
"\x74\x68\x69\x73\x20\x69\x73\x20\x77\x68\x61\x74\x20\x77\x65\x20\x70"
|
||||||
|
"\x6f\x73\x74\x20\x74\x6f\x20\x74\x68\x65\x20\x73\x69\x6c\x6c\x79\x20"
|
||||||
|
"\x77\x65\x62\x20\x73\x65\x72\x76\x65\x72\x0a";
|
||||||
|
#else
|
||||||
|
"this is what we post to the silly web server\n";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct WriteThis {
|
||||||
|
char *readptr;
|
||||||
|
size_t sizeleft;
|
||||||
|
};
|
||||||
|
|
||||||
|
static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
|
||||||
|
{
|
||||||
|
#ifdef LIB644
|
||||||
|
(void)ptr;
|
||||||
|
(void)size;
|
||||||
|
(void)nmemb;
|
||||||
|
(void)userp;
|
||||||
|
return CURL_READFUNC_ABORT;
|
||||||
|
#else
|
||||||
|
|
||||||
|
struct WriteThis *pooh = (struct WriteThis *)userp;
|
||||||
|
int eof = !*pooh->readptr;
|
||||||
|
|
||||||
|
if(size*nmemb < 1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
#ifndef LIB645
|
||||||
|
eof = !pooh->sizeleft;
|
||||||
|
if(!eof)
|
||||||
|
pooh->sizeleft--;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(!eof) {
|
||||||
|
*ptr = *pooh->readptr; /* copy one single byte */
|
||||||
|
pooh->readptr++; /* advance pointer */
|
||||||
|
return 1; /* we return 1 byte at a time! */
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0; /* no more data left to deliver */
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static int once(char *URL, bool oldstyle)
|
||||||
|
{
|
||||||
|
CURL *curl;
|
||||||
|
CURLcode res = CURLE_OK;
|
||||||
|
|
||||||
|
curl_mime *mime = NULL;
|
||||||
|
curl_mimepart *part = NULL;
|
||||||
|
struct WriteThis pooh;
|
||||||
|
struct WriteThis pooh2;
|
||||||
|
curl_off_t datasize = -1;
|
||||||
|
|
||||||
|
pooh.readptr = data;
|
||||||
|
#ifndef LIB645
|
||||||
|
datasize = strlen(data);
|
||||||
|
#endif
|
||||||
|
pooh.sizeleft = datasize;
|
||||||
|
|
||||||
|
curl = curl_easy_init();
|
||||||
|
if(!curl) {
|
||||||
|
fprintf(stderr, "curl_easy_init() failed\n");
|
||||||
|
curl_global_cleanup();
|
||||||
|
return TEST_ERR_MAJOR_BAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
mime = curl_mime_init(curl);
|
||||||
|
if(!mime) {
|
||||||
|
fprintf(stderr, "curl_mime_init() failed\n");
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
|
curl_global_cleanup();
|
||||||
|
return TEST_ERR_MAJOR_BAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
part = curl_mime_addpart(mime);
|
||||||
|
if(!part) {
|
||||||
|
fprintf(stderr, "curl_mime_addpart(1) failed\n");
|
||||||
|
curl_mime_free(mime);
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
|
curl_global_cleanup();
|
||||||
|
return TEST_ERR_MAJOR_BAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fill in the file upload part */
|
||||||
|
if(oldstyle) {
|
||||||
|
res = curl_mime_name(part, "sendfile", -1);
|
||||||
|
if(!res)
|
||||||
|
res = curl_mime_data_cb(part, datasize, read_callback,
|
||||||
|
NULL, NULL, &pooh);
|
||||||
|
if(!res)
|
||||||
|
res = curl_mime_filename(part, "postit2.c");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* new style */
|
||||||
|
res = curl_mime_name(part, "sendfile alternative", -1);
|
||||||
|
if(!res)
|
||||||
|
res = curl_mime_data_cb(part, datasize, read_callback,
|
||||||
|
NULL, NULL, &pooh);
|
||||||
|
if(!res)
|
||||||
|
res = curl_mime_filename(part, "file name 2");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(res)
|
||||||
|
printf("curl_mime_xxx(1) = %s\n", curl_easy_strerror(res));
|
||||||
|
|
||||||
|
/* Now add the same data with another name and make it not look like
|
||||||
|
a file upload but still using the callback */
|
||||||
|
|
||||||
|
pooh2.readptr = data;
|
||||||
|
#ifndef LIB645
|
||||||
|
datasize = strlen(data);
|
||||||
|
#endif
|
||||||
|
pooh2.sizeleft = datasize;
|
||||||
|
|
||||||
|
part = curl_mime_addpart(mime);
|
||||||
|
if(!part) {
|
||||||
|
fprintf(stderr, "curl_mime_addpart(2) failed\n");
|
||||||
|
curl_mime_free(mime);
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
|
curl_global_cleanup();
|
||||||
|
return TEST_ERR_MAJOR_BAD;
|
||||||
|
}
|
||||||
|
/* Fill in the file upload part */
|
||||||
|
res = curl_mime_name(part, "callbackdata", -1);
|
||||||
|
if(!res)
|
||||||
|
res = curl_mime_data_cb(part, datasize, read_callback,
|
||||||
|
NULL, NULL, &pooh2);
|
||||||
|
|
||||||
|
if(res)
|
||||||
|
printf("curl_mime_xxx(2) = %s\n", curl_easy_strerror(res));
|
||||||
|
|
||||||
|
part = curl_mime_addpart(mime);
|
||||||
|
if(!part) {
|
||||||
|
fprintf(stderr, "curl_mime_addpart(3) failed\n");
|
||||||
|
curl_mime_free(mime);
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
|
curl_global_cleanup();
|
||||||
|
return TEST_ERR_MAJOR_BAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fill in the filename field */
|
||||||
|
res = curl_mime_name(part, "filename", -1);
|
||||||
|
if(!res)
|
||||||
|
res = curl_mime_data(part,
|
||||||
|
#ifdef CURL_DOES_CONVERSIONS
|
||||||
|
/* ASCII representation with escape
|
||||||
|
sequences for non-ASCII platforms */
|
||||||
|
"\x70\x6f\x73\x74\x69\x74\x32\x2e\x63",
|
||||||
|
#else
|
||||||
|
"postit2.c",
|
||||||
|
#endif
|
||||||
|
-1);
|
||||||
|
|
||||||
|
if(res)
|
||||||
|
printf("curl_mime_xxx(3) = %s\n", curl_easy_strerror(res));
|
||||||
|
|
||||||
|
/* Fill in a submit field too */
|
||||||
|
part = curl_mime_addpart(mime);
|
||||||
|
if(!part) {
|
||||||
|
fprintf(stderr, "curl_mime_addpart(4) failed\n");
|
||||||
|
curl_mime_free(mime);
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
|
curl_global_cleanup();
|
||||||
|
return TEST_ERR_MAJOR_BAD;
|
||||||
|
}
|
||||||
|
res = curl_mime_name(part, "submit", -1);
|
||||||
|
if(!res)
|
||||||
|
res = curl_mime_data(part,
|
||||||
|
#ifdef CURL_DOES_CONVERSIONS
|
||||||
|
/* ASCII representation with escape
|
||||||
|
sequences for non-ASCII platforms */
|
||||||
|
"\x73\x65\x6e\x64",
|
||||||
|
#else
|
||||||
|
"send",
|
||||||
|
#endif
|
||||||
|
-1);
|
||||||
|
|
||||||
|
if(res)
|
||||||
|
printf("curl_mime_xxx(4) = %s\n", curl_easy_strerror(res));
|
||||||
|
|
||||||
|
part = curl_mime_addpart(mime);
|
||||||
|
if(!part) {
|
||||||
|
fprintf(stderr, "curl_mime_addpart(5) failed\n");
|
||||||
|
curl_mime_free(mime);
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
|
curl_global_cleanup();
|
||||||
|
return TEST_ERR_MAJOR_BAD;
|
||||||
|
}
|
||||||
|
res = curl_mime_name(part, "somename", -1);
|
||||||
|
if(!res)
|
||||||
|
res = curl_mime_filename(part, "somefile.txt");
|
||||||
|
if(!res)
|
||||||
|
res = curl_mime_data(part, "blah blah", 9);
|
||||||
|
|
||||||
|
if(res)
|
||||||
|
printf("curl_mime_xxx(5) = %s\n", curl_easy_strerror(res));
|
||||||
|
|
||||||
|
/* First set the URL that is about to receive our POST. */
|
||||||
|
test_setopt(curl, CURLOPT_URL, URL);
|
||||||
|
|
||||||
|
/* send a multi-part mimepost */
|
||||||
|
test_setopt(curl, CURLOPT_MIMEPOST, mime);
|
||||||
|
|
||||||
|
/* get verbose debug output please */
|
||||||
|
test_setopt(curl, CURLOPT_VERBOSE, 1L);
|
||||||
|
|
||||||
|
/* include headers in the output */
|
||||||
|
test_setopt(curl, CURLOPT_HEADER, 1L);
|
||||||
|
|
||||||
|
/* Perform the request, res will get the return code */
|
||||||
|
res = curl_easy_perform(curl);
|
||||||
|
|
||||||
|
test_cleanup:
|
||||||
|
|
||||||
|
/* always cleanup */
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
|
|
||||||
|
/* now cleanup the mimepost structure */
|
||||||
|
curl_mime_free(mime);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
@ -5,7 +5,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -71,7 +71,7 @@ UNITTEST_START
|
|||||||
|
|
||||||
fail_unless(rc == 0, "curl_formget returned error");
|
fail_unless(rc == 0, "curl_formget returned error");
|
||||||
|
|
||||||
fail_unless(total_size == 486, "curl_formget got wrong size back");
|
fail_unless(total_size == 488, "curl_formget got wrong size back");
|
||||||
|
|
||||||
curl_formfree(post);
|
curl_formfree(post);
|
||||||
|
|
||||||
@ -88,7 +88,7 @@ UNITTEST_START
|
|||||||
|
|
||||||
rc = curl_formget(post, &total_size, print_httppost_callback);
|
rc = curl_formget(post, &total_size, print_httppost_callback);
|
||||||
fail_unless(rc == 0, "curl_formget returned error");
|
fail_unless(rc == 0, "curl_formget returned error");
|
||||||
fail_unless(total_size == 847, "curl_formget got wrong size back");
|
fail_unless(total_size == 851, "curl_formget got wrong size back");
|
||||||
|
|
||||||
curl_formfree(post);
|
curl_formfree(post);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user