Marcus Webster's newly added CURLFORM_CONTENTHEADER
authorDaniel Stenberg <daniel@haxx.se>
Fri, 14 Dec 2001 12:59:16 +0000 (12:59 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 14 Dec 2001 12:59:16 +0000 (12:59 +0000)
CHANGES
docs/THANKS
include/curl/curl.h
lib/formdata.c
lib/formdata.h

diff --git a/CHANGES b/CHANGES
index 17319fefdf3f7bac0b726437022028f61ae3544f..b98076d4c6a74b4235823899c98827c3d926a12c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,25 @@
 
                                History of Changes
 
+Daniel (14 December 2001)
+- Marcus Webster provided code for the new CURLFORM_CONTENTHEADER option for
+  curl_formadd(), that lets an application add a set of headers for that
+  particular part in a multipart/form-post. We need to add 
+
+Daniel (11 December 2001)
+- Ben Greear made me aware of the fact that the Curl_failf() usage internally
+  was a bit sloppy with adding newlines or not to the error messages. Let's
+  once and for all say that they do not belong there!
+
+- When uploading files with -T to give a local file name, and you end the URL
+  with a slash to have the local file name used remote too, we now no longer
+  use the local directory as well. Only the file part of the -T file name
+  will be appended to the right of the slash in the URL.
+
+Daniel (7 December 2001)
+- Michal Bonino pointed out that Digital Unix doesn't have gmtime_r so the
+  link failed. Added a configure check and corrected source code.
+
 Version 7.9.2
 
 Daniel (5 December 2001)
index d46c933a0823388f8e1fe49e90a17f36df72dfad..04e5f9f1a4cfea6df6c2d6fefb7876721e7fea02 100644 (file)
@@ -76,3 +76,5 @@ that have contributed with non-trivial parts:
  - Tomasz Lacki <Tomasz.Lacki@primark.pl>
  - Georg Huettenegger <georg@ist.org>
  - John Lask <johnlask@hotmail.com>
+ - Eric Lavigne <erlavigne@wanadoo.fr>
+ - Marcus Webster <marcus.webster@phocis.com>
index 4a89467d4b14801c6ac3964be7fd8baad1763284..6ce918e53272228364e3830c498c53f20d4ee80b 100644 (file)
@@ -62,6 +62,7 @@ struct HttpPost {
   char *contents; /* pointer to allocated data contents */
   long contentslength; /* length of contents field */
   char *contenttype; /* Content-Type */
+  struct curl_slist* contentheader; /* list of extra headers for this form */
   struct HttpPost *more; /* if one field name has more than one file, this
                            link should link to following files */
   long flags;     /* as defined below */
@@ -543,6 +544,7 @@ typedef enum {
   CFINIT(ARRAY_START), /* below are the options allowed within a array */
   CFINIT(FILE),
   CFINIT(CONTENTTYPE),
+  CFINIT(CONTENTHEADER),
   CFINIT(END),
   CFINIT(ARRAY_END),   /* up are the options allowed within a array */
 
index ef5e153748d0eac39b4cfe701092d302134f148e..c767da9fc573688c22bd57be767e83285022365b 100644 (file)
@@ -396,15 +396,16 @@ int curl_formparse(char *input,
  * Returns newly allocated HttpPost on success and NULL if malloc failed.
  *
  ***************************************************************************/
-static struct HttpPost * AddHttpPost (char * name,
-                                      long namelength,
-                                      char * value,
-                                      long contentslength,
-                                     char *contenttype,
-                                      long flags,
-                                      struct HttpPost *parent_post,
-                                      struct HttpPost **httppost,
-                                      struct HttpPost **last_post)
+static struct HttpPost * AddHttpPost(char * name,
+                                     long namelength,
+                                     char * value,
+                                     long contentslength,
+                                     char *contenttype,
+                                     long flags,
+                                     struct curl_slist* contentHeader,
+                                     struct HttpPost *parent_post,
+                                     struct HttpPost **httppost,
+                                     struct HttpPost **last_post)
 {
   struct HttpPost *post;
   post = (struct HttpPost *)malloc(sizeof(struct HttpPost));
@@ -415,6 +416,7 @@ static struct HttpPost * AddHttpPost (char * name,
     post->contents = value;
     post->contentslength = contentslength;
     post->contenttype = contenttype;
+    post->contentheader = contentHeader;
     post->flags = flags;
   }
   else
@@ -823,6 +825,21 @@ FORMcode FormAdd(struct HttpPost **httppost,
        }
         break;
       }
+    case CURLFORM_CONTENTHEADER:
+      {
+        struct curl_slist* list = NULL;
+        if( array_state )
+          list = (struct curl_slist*)array_value;
+        else
+          list = va_arg(params,struct curl_slist*);
+        
+        if( current_form->contentheader )
+          return_value = FORMADD_OPTION_TWICE;
+        else
+          current_form->contentheader = list;
+        
+        break;
+      }
     default:
       fprintf (stderr, "got unknown CURLFORM_OPTION: %d\n", option);
       return_value = FORMADD_UNKNOWN_OPTION;
@@ -872,13 +889,16 @@ FORMcode FormAdd(struct HttpPost **httppost,
             break;
           }
         }
-        if ( (post = AddHttpPost(form->name, form->namelength,
-                                 form->value, form->contentslength,
-                                 form->contenttype, form->flags,
-                                 post, httppost,
-                                 last_post)) == NULL) {
+        post = AddHttpPost(form->name, form->namelength,
+                           form->value, form->contentslength,
+                           form->contenttype, form->flags,
+                           form->contentheader,
+                           post, httppost,
+                           last_post);
+        
+        if(!post)
           return_value = FORMADD_MEMORY;
-        }
+
         if (form->contenttype)
           prevtype = form->contenttype;
       }
@@ -1029,6 +1049,8 @@ struct FormData *Curl_getFormData(struct HttpPost *post,
   int size =0;
   char *boundary;
   char *fileboundary=NULL;
+  struct curl_slist* curList;
+
 
   if(!post)
     return NULL; /* no input => no output! */
@@ -1090,6 +1112,13 @@ struct FormData *Curl_getFormData(struct HttpPost *post,
                             file->contenttype);
       }
 
+      curList = file->contentheader;
+      while( curList ) {
+        /* Process the additional headers specified for this form */
+        size += AddFormDataf( &form, "\r\n%s", curList->data );
+        curList = curList->next;
+      }
+
 #if 0
       /* The header Content-Transfer-Encoding: seems to confuse some receivers
        * (like the built-in PHP engine). While I can't see any reason why it
index bca1f9fcc94debd06939a9f5d0de40dce2afad72..40f8c9472cc14126e954541ad6715c30e584ae2b 100644 (file)
@@ -44,6 +44,7 @@ typedef struct FormInfo {
   long contentslength;
   char *contenttype;
   long flags;
+  struct curl_slist* contentheader;
   struct FormInfo *more;
 } FormInfo;