summaryrefslogtreecommitdiff
path: root/lib/mime.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2018-02-04 09:23:11 +0100
committerDaniel Stenberg <daniel@haxx.se>2018-02-05 13:50:30 +0100
commit84ad1fd3047815f9c6e78728bb351b828eac10b1 (patch)
tree31e2d053c836cf6bde3ae02a248e325a4c433bdf /lib/mime.c
parenta19afaccfeb5a77c15fdfc1c2be16fb27828cefc (diff)
downloadcurl-84ad1fd3047815f9c6e78728bb351b828eac10b1.tar.gz
formdata: use the mime-content type function
Reduce code duplication by making Curl_mime_contenttype available and used by the formdata function. This also makes the formdata function recognize a set of more file extensions by default. PR #2280 brought this to my attention. Closes #2282
Diffstat (limited to 'lib/mime.c')
-rw-r--r--lib/mime.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/lib/mime.c b/lib/mime.c
index e0853a9ed..0ccb346ee 100644
--- a/lib/mime.c
+++ b/lib/mime.c
@@ -51,10 +51,6 @@
#endif
-#define FILE_CONTENTTYPE_DEFAULT "application/octet-stream"
-#define MULTIPART_CONTENTTYPE_DEFAULT "multipart/mixed"
-#define DISPOSITION_DEFAULT "attachment"
-
#define READ_ERROR ((size_t) -1)
/* Encoders. */
@@ -1642,8 +1638,7 @@ static CURLcode add_content_type(struct curl_slist **slp,
boundary? boundary: "");
}
-
-static const char *ContentTypeForFilename(const char *filename)
+const char *Curl_mime_contenttype(const char *filename)
{
unsigned int i;
@@ -1715,14 +1710,14 @@ CURLcode Curl_mime_prepare_headers(curl_mimepart *part,
contenttype = MULTIPART_CONTENTTYPE_DEFAULT;
break;
case MIMEKIND_FILE:
- contenttype = ContentTypeForFilename(part->filename);
+ contenttype = Curl_mime_contenttype(part->filename);
if(!contenttype)
- contenttype = ContentTypeForFilename(part->data);
+ contenttype = Curl_mime_contenttype(part->data);
if(!contenttype && part->filename)
contenttype = FILE_CONTENTTYPE_DEFAULT;
break;
default:
- contenttype = ContentTypeForFilename(part->filename);
+ contenttype = Curl_mime_contenttype(part->filename);
break;
}
}