aboutsummaryrefslogtreecommitdiff
path: root/lib/mime.c
diff options
context:
space:
mode:
authorPatrick Monnerat <patrick@monnerat.net>2017-10-12 19:36:16 +0100
committerPatrick Monnerat <patrick@monnerat.net>2017-10-12 19:36:16 +0100
commit0401734dfd39617a42318295a6e54064b40b2502 (patch)
tree823fce7c271e1a8ee7447260b9c690050f0c5c9e /lib/mime.c
parent56509055d23986479f472d667625426f51074992 (diff)
mime: keep "text/plain" content type if user-specified.
Include test cases in 554, 587, 650. Fixes https://github.com/curl/curl/issues/1986
Diffstat (limited to 'lib/mime.c')
-rw-r--r--lib/mime.c19
1 files changed, 11 insertions, 8 deletions
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;