--- formdata.c-7.15.4.orig	Wed Jul 26 15:49:08 2006
+++ formdata.c	Wed Jul 26 15:32:45 2006
@@ -984,10 +984,13 @@
  * (possibly huge) multipart formdata. The input list is in 'post', while the
  * output resulting linked lists gets stored in '*finalform'. *sizep will get
  * the total size of the whole POST.
+ * A multipart/form_data content-type is built, unless a custom content-type
+ * is passed in 'custom_content_type'.
  */
 
 CURLcode Curl_getFormData(struct FormData **finalform,
                           struct curl_httppost *post,
+                          const char *custom_content_type,
                           curl_off_t *sizep)
 {
   struct FormData *form = NULL;
@@ -1010,10 +1013,28 @@
     return CURLE_OUT_OF_MEMORY;
 
   /* Make the first line of the output */
-  result = AddFormDataf(&form, NULL,
-                        "Content-Type: multipart/form-data;"
-                        " boundary=%s\r\n",
-                        boundary);
+  if (custom_content_type) {
+    if (strchr(custom_content_type, ';')) {
+      /* the custom content-type already contains parameters: add the boundary as a new parameter */
+      result = AddFormDataf(&form, NULL,
+                            "%s, boundary=%s\r\n",
+                            custom_content_type, boundary);
+    }
+    else {
+      /* the custom content-type does not contains parameters: add a ';' before the boundary */
+      result = AddFormDataf(&form, NULL,
+                            "%s; boundary=%s\r\n",
+                            custom_content_type, boundary);
+    }
+  }
+  else {
+    /* by default we build a multipart/form-data */
+    result = AddFormDataf(&form, NULL,
+                          "Content-Type: multipart/form-data;"
+                          " boundary=%s\r\n",
+                          boundary);
+  }
+
   if (result) {
     free(boundary);
     return result;
@@ -1036,6 +1057,9 @@
     if (result)
       break;
 
+    /* Maybe later this should be disabled when a custom_content_type is passed,
+    since Content-Disposition is not meaningful for all multipart types.
+    */
     result = AddFormDataf(&form, &size,
                           "Content-Disposition: form-data; name=\"");
     if (result)
