mirror of
https://github.com/curl/curl.git
synced 2026-07-30 18:28:08 +03:00
mime: keep "text/plain" content type if user-specified.
Include test cases in 554, 587, 650. Fixes https://github.com/curl/curl/issues/1986
This commit is contained in:
parent
56509055d2
commit
0401734dfd
7 changed files with 35 additions and 27 deletions
|
|
@ -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. */
|
||||
|
|
|
|||
19
lib/mime.c
19
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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue