[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 47/73: mime: keep "text/plain" content type if user
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 47/73: mime: keep "text/plain" content type if user-specified. |
Date: |
Tue, 24 Oct 2017 18:54:28 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit 0401734dfd39617a42318295a6e54064b40b2502
Author: Patrick Monnerat <address@hidden>
AuthorDate: Thu Oct 12 19:36:16 2017 +0100
mime: keep "text/plain" content type if user-specified.
Include test cases in 554, 587, 650.
Fixes https://github.com/curl/curl/issues/1986
---
lib/formdata.c | 2 +-
lib/mime.c | 19 +++++++++++--------
tests/data/test554 | 6 ++++--
tests/data/test587 | 2 +-
tests/data/test650 | 9 +++++----
tests/libtest/lib554.c | 9 +++++----
tests/libtest/lib650.c | 15 ++++++++-------
7 files changed, 35 insertions(+), 27 deletions(-)
diff --git a/lib/formdata.c b/lib/formdata.c
index 3568ac579..d0579c52f 100644
--- a/lib/formdata.c
+++ b/lib/formdata.c
@@ -907,7 +907,7 @@ CURLcode Curl_getformdata(struct Curl_easy *data,
result = curl_mime_headers(part, file->contentheader, 0);
/* Set the content type. */
- if(!result &&file->contenttype)
+ if(!result && file->contenttype)
result = curl_mime_type(part, file->contenttype);
/* Set field name. */
diff --git a/lib/mime.c b/lib/mime.c
index cba95b929..1868336ca 100644
--- a/lib/mime.c
+++ b/lib/mime.c
@@ -1619,7 +1619,7 @@ CURLcode Curl_mime_prepare_headers(curl_mimepart *part,
{
curl_mime *mime = NULL;
const char *boundary = NULL;
- char *s;
+ char *customct;
const char *cte = NULL;
CURLcode ret = CURLE_OK;
@@ -1631,12 +1631,14 @@ CURLcode Curl_mime_prepare_headers(curl_mimepart *part,
if(part->state.state == MIMESTATE_CURLHEADERS)
mimesetstate(&part->state, MIMESTATE_CURLHEADERS, NULL);
- /* Build the content-type header. */
- s = search_header(part->userheaders, "Content-Type");
- if(s)
- contenttype = s;
- if(part->mimetype)
- contenttype = part->mimetype;
+ /* Check if content type is specified. */
+ customct = part->mimetype;
+ if(!customct)
+ customct = search_header(part->userheaders, "Content-Type");
+ if(customct)
+ contenttype = customct;
+
+ /* If content type is not specified, try to determine it. */
if(!contenttype) {
switch(part->kind) {
case MIMEKIND_MULTIPART:
@@ -1660,7 +1662,8 @@ CURLcode Curl_mime_prepare_headers(curl_mimepart *part,
if(mime)
boundary = mime->boundary;
}
- else if(contenttype && strcasecompare(contenttype, "text/plain"))
+ else if(contenttype && !customct &&
+ strcasecompare(contenttype, "text/plain"))
if(strategy == MIMESTRATEGY_MAIL || !part->filename)
contenttype = NULL;
diff --git a/tests/data/test554 b/tests/data/test554
index ce4a14dc4..24d9c0468 100644
--- a/tests/data/test554
+++ b/tests/data/test554
@@ -68,7 +68,7 @@
s/boundary=------------------------[a-z0-9]*/boundary=--------------------------
POST /554 HTTP/1.1
Host: %HOSTIP:%HTTPPORT
Accept: */*
-Content-Length: 718
+Content-Length: 744
Content-Type: multipart/form-data; boundary=----------------------------
------------------------------
@@ -87,6 +87,7 @@ Content-Disposition: form-data; name="filename"
postit2.c
------------------------------
Content-Disposition: form-data; name="submit"
+Content-Type: text/plain
send
------------------------------
@@ -98,7 +99,7 @@ blah blah
POST /554 HTTP/1.1
Host: %HOSTIP:%HTTPPORT
Accept: */*
-Content-Length: 732
+Content-Length: 758
Content-Type: multipart/form-data; boundary=----------------------------
------------------------------
@@ -117,6 +118,7 @@ Content-Disposition: form-data; name="filename"
postit2.c
------------------------------
Content-Disposition: form-data; name="submit"
+Content-Type: text/plain
send
------------------------------
diff --git a/tests/data/test587 b/tests/data/test587
index 5a845d431..0d9530e93 100644
--- a/tests/data/test587
+++ b/tests/data/test587
@@ -43,7 +43,7 @@
s/boundary=------------------------[a-z0-9]*/boundary=--------------------------
POST /587 HTTP/1.1
Host: %HOSTIP:%HTTPPORT
Accept: */*
-Content-Length: 718
+Content-Length: 744
Content-Type: multipart/form-data; boundary=----------------------------
------------------------------
diff --git a/tests/data/test650 b/tests/data/test650
index e07d4c10b..1a06064c7 100644
--- a/tests/data/test650
+++ b/tests/data/test650
@@ -63,9 +63,12 @@ Transfer-Encoding: chunked
Content-Type: multipart/form-data; boundary=----------------------------
Expect: 100-continue
-5f0
+60a
------------------------------
Content-Disposition: form-data; name="fieldname"
+Content-Type: text/plain
+X-customheader-1: Header 1 data
+X-customheader-2: Header 2 data
this is what we post to the silly web server
------------------------------
@@ -98,15 +101,13 @@ This is data from a file.
------------------------------
Content-Disposition: form-data; name="filecontents"
-X-customheader-1: Header 1 data
-X-customheader-2: Header 2 data
This is data from a file.
------------------------------
Content-Disposition: form-data; name="formlength"
-1341
+1367
------------------------------
Content-Disposition: form-data; name="standardinput"
Content-Type: application/octet-stream
diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c
index 936d0a10a..cc21d245b 100644
--- a/tests/libtest/lib554.c
+++ b/tests/libtest/lib554.c
@@ -117,7 +117,7 @@ static int once(char *URL, bool oldstyle)
CURLFORM_END);
if(formrc)
- printf("curl_formadd(1) = %d\n", (int)formrc);
+ printf("curl_formadd(2) = %d\n", (int)formrc);
/* Fill in the filename field */
formrc = curl_formadd(&formpost,
@@ -134,7 +134,7 @@ static int once(char *URL, bool oldstyle)
CURLFORM_END);
if(formrc)
- printf("curl_formadd(2) = %d\n", (int)formrc);
+ printf("curl_formadd(3) = %d\n", (int)formrc);
/* Fill in a submit field too */
formrc = curl_formadd(&formpost,
@@ -147,10 +147,11 @@ static int once(char *URL, bool oldstyle)
#else
CURLFORM_COPYCONTENTS, "send",
#endif
+ CURLFORM_CONTENTTYPE, "text/plain",
CURLFORM_END);
if(formrc)
- printf("curl_formadd(3) = %d\n", (int)formrc);
+ printf("curl_formadd(4) = %d\n", (int)formrc);
formrc = curl_formadd(&formpost, &lastptr,
CURLFORM_COPYNAME, "somename",
@@ -160,7 +161,7 @@ static int once(char *URL, bool oldstyle)
CURLFORM_END);
if(formrc)
- printf("curl_formadd(4) = %d\n", (int)formrc);
+ printf("curl_formadd(5) = %d\n", (int)formrc);
curl = curl_easy_init();
if(!curl) {
diff --git a/tests/libtest/lib650.c b/tests/libtest/lib650.c
index 130ef1e77..60a2e9f1d 100644
--- a/tests/libtest/lib650.c
+++ b/tests/libtest/lib650.c
@@ -68,10 +68,14 @@ int test(char *URL)
return TEST_ERR_MAJOR_BAD;
}
- /* Check proper name and data copying. */
+ /* Check proper name and data copying, as well as headers. */
+ headers = curl_slist_append(headers, "X-customheader-1: Header 1 data");
+ headers = curl_slist_append(headers, "X-customheader-2: Header 2 data");
+ headers = curl_slist_append(headers, "Content-Type: text/plain");
formrc = curl_formadd(&formpost, &lastptr,
CURLFORM_COPYNAME, &name,
CURLFORM_COPYCONTENTS, &data,
+ CURLFORM_CONTENTHEADER, headers,
CURLFORM_END);
if(formrc)
@@ -113,18 +117,15 @@ int test(char *URL)
if(formrc)
printf("curl_formadd(3) = %d\n", (int) formrc);
- /* Check data from file content and headers. */
- headers = curl_slist_append(headers, "X-customheader-1: Header 1 data");
- headers = curl_slist_append(headers, "X-customheader-2: Header 2 data");
+ /* Check data from file content. */
formrc = curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "filecontents",
CURLFORM_FILECONTENT, libtest_arg2,
- CURLFORM_CONTENTHEADER, headers,
CURLFORM_END);
if(formrc)
- printf("curl_formadd(3) = %d\n", (int) formrc);
+ printf("curl_formadd(4) = %d\n", (int) formrc);
/* Measure the current form length.
* This is done before including stdin data because we want to reuse it
@@ -148,7 +149,7 @@ int test(char *URL)
CURLFORM_END);
if(formrc)
- printf("curl_formadd(4) = %d\n", (int) formrc);
+ printf("curl_formadd(5) = %d\n", (int) formrc);
curl = curl_easy_init();
if(!curl) {
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnurl] 22/73: RELEASE-NOTES: synced with a4c1c75da30af1, (continued)
- [GNUnet-SVN] [gnurl] 22/73: RELEASE-NOTES: synced with a4c1c75da30af1, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 39/73: test950; verify SMTP with custom request, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 30/73: curl: don't pass semicolons when parsing Content-Disposition, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 42/73: RELEASE-NOTES: synced with 5505df7d2, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 44/73: winbuild/BUILD.WINDOWS.txt: mention WITH_NGHTTP2, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 15/73: pingpong: return error when trying to send without connection, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 45/73: cli tool: reimplement stdin buffering in -F option., gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 67/73: ftp: reject illegal IP/port in PASV 227 response, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 54/73: ldap: silence clang warning, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 51/73: configure: remove the C++ compiler check, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 47/73: mime: keep "text/plain" content type if user-specified.,
gnunet <=
- [GNUnet-SVN] [gnurl] 56/73: setopt: avoid integer overflows when setting millsecond values, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 52/73: memdebug: trace send, recv and socket, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 64/73: test308: disable if MultiSSL feature enabled, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 71/73: THANKS: update at 7.56.1 release time, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 68/73: imap: if a FETCH response has no size, don't call write callback, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 61/73: os400: add missing symbols in config file., gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 17/73: remove_handle: call multi_done() first, then clear dns cache pointer, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 38/73: ftpserver: support case insensitive commands, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 16/73: multi_done: wait for name resolve to finish if still ongoing, gnunet, 2017/10/24
- [GNUnet-SVN] [gnurl] 06/73: docs: fix typo in curl_mime_data_cb man page, gnunet, 2017/10/24