mirror of
https://github.com/curl/curl.git
synced 2026-07-28 13:53:07 +03:00
mime: implement encoders.
curl_mime_encoder() is operational and documented. curl tool -F option is extended with ";encoder=". curl tool --libcurl option generates calls to curl_mime_encoder(). New encoder tests 648 & 649. Test 1404 extended with an encoder specification.
This commit is contained in:
parent
3bbe894fd2
commit
63ef436ea1
12 changed files with 809 additions and 45 deletions
|
|
@ -78,7 +78,7 @@ test608 test609 test610 test611 test612 test613 test614 test615 test616 \
|
|||
test617 test618 test619 test620 test621 test622 test623 test624 test625 \
|
||||
test626 test627 test628 test629 test630 test631 test632 test633 test634 \
|
||||
test635 test636 test637 test638 test639 test640 test641 test642 \
|
||||
test643 test644 test645 test646 test647 \
|
||||
test643 test644 test645 test646 test647 test648 test649 \
|
||||
\
|
||||
test700 test701 test702 test703 test704 test705 test706 test707 test708 \
|
||||
test709 test710 test711 test712 test713 test714 test715 \
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@ Connection: close
|
|||
http
|
||||
</server>
|
||||
<name>
|
||||
--libcurl for HTTP RFC1867-type formposting - -F with three files, one with explicit type
|
||||
--libcurl for HTTP RFC1867-type formposting - -F with 3 files, one with explicit type & encoder
|
||||
</name>
|
||||
<setenv>
|
||||
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;headers=X-testheader-1: header 1;headers=X-testheader-2: header 2' --libcurl log/test1404.c
|
||||
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
|
||||
</command>
|
||||
# We create this file before the command is invoked!
|
||||
<file name="log/test1404.txt">
|
||||
|
|
@ -51,7 +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: 849
|
||||
Content-Length: 882
|
||||
Content-Type: multipart/form-data; boundary=----------------------------9ef8d6205763
|
||||
|
||||
------------------------------9ef8d6205763
|
||||
|
|
@ -70,6 +70,7 @@ dummy data
|
|||
------------------------------9ef8d6205763
|
||||
Content-Disposition: attachment; filename="test1404.txt"
|
||||
Content-Type: magic/content
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
dummy data
|
||||
|
||||
|
|
@ -131,6 +132,7 @@ int main(int argc, char *argv[])
|
|||
curl_mime_filedata(part2, "log/test1404.txt");
|
||||
part2 = curl_mime_addpart(mime2);
|
||||
curl_mime_filedata(part2, "log/test1404.txt");
|
||||
curl_mime_encoder(part2, "8bit");
|
||||
curl_mime_type(part2, "magic/content");
|
||||
part2 = curl_mime_addpart(mime2);
|
||||
curl_mime_filedata(part2, "log/test1404.txt");
|
||||
|
|
|
|||
75
tests/data/test648
Normal file
75
tests/data/test648
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<testcase>
|
||||
<info>
|
||||
<keywords>
|
||||
SMTP
|
||||
MULTIPART
|
||||
</keywords>
|
||||
</info>
|
||||
|
||||
#
|
||||
# Server-side
|
||||
<reply>
|
||||
</reply>
|
||||
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
smtp
|
||||
</server>
|
||||
<name>
|
||||
SMTP multipart with transfer content encoders
|
||||
</name>
|
||||
<stdin>
|
||||
From: different
|
||||
To: another
|
||||
|
||||
body
|
||||
</stdin>
|
||||
<command>
|
||||
smtp://%HOSTIP:%SMTPPORT/648 --mail-rcpt recipient@example.com --mail-from sender@example.com -F '=This is the e-mail inline text with a very long line containing the special character = and that should be split by encoder.;headers=Content-disposition: "inline";encoder=quoted-printable' -F "=@log/test648.txt;encoder=base64" -H "From: different" -H "To: another"
|
||||
</command>
|
||||
<file name="log/test648.txt">
|
||||
This is an attached file.
|
||||
|
||||
It may contain any type of data and will be encoded in base64 for transfer.
|
||||
</file>
|
||||
</client>
|
||||
|
||||
#
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<strippart>
|
||||
s/^--------------------------[a-z0-9]*/------------------------------/
|
||||
s/boundary=------------------------[a-z0-9]*/boundary=----------------------------/
|
||||
</strippart>
|
||||
<protocol>
|
||||
EHLO 648
|
||||
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
|
||||
|
||||
------------------------------
|
||||
Content-Transfer-Encoding: quoted-printable
|
||||
Content-disposition: "inline"
|
||||
|
||||
This is the e-mail inline text with a very long line containing the special=
|
||||
character =3D and that should be split by encoder.
|
||||
------------------------------
|
||||
Content-Disposition: attachment; filename="test648.txt"
|
||||
Content-Transfer-Encoding: base64
|
||||
|
||||
VGhpcyBpcyBhbiBhdHRhY2hlZCBmaWxlLgoKSXQgbWF5IGNvbnRhaW4gYW55IHR5cGUgb2Yg
|
||||
ZGF0YSBhbmQgd2lsbCBiZSBlbmNvZGVkIGluIGJhc2U2NCBmb3IgdHJhbnNmZXIuCg==
|
||||
--------------------------------
|
||||
.
|
||||
</upload>
|
||||
</verify>
|
||||
</testcase>
|
||||
72
tests/data/test649
Normal file
72
tests/data/test649
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
<testcase>
|
||||
<info>
|
||||
<keywords>
|
||||
SMTP
|
||||
MULTIPART
|
||||
</keywords>
|
||||
</info>
|
||||
|
||||
#
|
||||
# Server-side
|
||||
<reply>
|
||||
</reply>
|
||||
|
||||
#
|
||||
# Client-side
|
||||
<client>
|
||||
<server>
|
||||
smtp
|
||||
</server>
|
||||
<name>
|
||||
SMTP multipart with 7bit encoder error
|
||||
</name>
|
||||
<stdin>
|
||||
From: different
|
||||
To: another
|
||||
|
||||
body
|
||||
</stdin>
|
||||
<command>
|
||||
smtp://%HOSTIP:%SMTPPORT/649 --mail-rcpt recipient@example.com --mail-from sender@example.com -F '=This is valid;encoder=7bit' -F "=@log/test649.txt;encoder=7bit" -H "From: different" -H "To: another"
|
||||
</command>
|
||||
<file name="log/test649.txt">
|
||||
This is an attached file (in french: pièce jointe).
|
||||
|
||||
It contains at least an 8-bit byte value.
|
||||
</file>
|
||||
</client>
|
||||
|
||||
#
|
||||
# Verify data after the test has been "shot"
|
||||
<verify>
|
||||
<strippart>
|
||||
s/^--------------------------[a-z0-9]*/------------------------------/
|
||||
s/boundary=------------------------[a-z0-9]*/boundary=----------------------------/
|
||||
</strippart>
|
||||
<protocol>
|
||||
EHLO 649
|
||||
MAIL FROM:<sender@example.com>
|
||||
RCPT TO:<recipient@example.com>
|
||||
DATA
|
||||
</protocol>
|
||||
<upload nonewline="yes">
|
||||
Content-Type: multipart/mixed; boundary=----------------------------
|
||||
Mime-Version: 1.0
|
||||
From: different
|
||||
To: another
|
||||
|
||||
------------------------------
|
||||
Content-Transfer-Encoding: 7bit
|
||||
|
||||
This is valid
|
||||
------------------------------
|
||||
Content-Disposition: attachment; filename="test649.txt"
|
||||
Content-Transfer-Encoding: 7bit
|
||||
|
||||
This is an attached file (in french: pi
|
||||
</upload>
|
||||
<errorcode>
|
||||
26
|
||||
</errorcode>
|
||||
</verify>
|
||||
</testcase>
|
||||
Loading…
Add table
Add a link
Reference in a new issue