aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-09-10 21:47:52 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-09-10 21:47:52 +0000
commit0ec4c66fbaea2d024e4efa16a608e9099ef49de3 (patch)
tree9773b5af93f6a8e8b91d038247c745b5ba1a4bd6 /src
parent1faa9d6fd5a1d18f7181402959054f548389d91f (diff)
fixed -F to support setting type= even on parts that aren't file-uploads
Diffstat (limited to 'src')
-rw-r--r--src/main.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/main.c b/src/main.c
index 03c854d1a..87886ad6c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -920,19 +920,42 @@ static int formparse(char *input,
}
}
else {
+ struct curl_forms info[4];
+ int i = 0;
+ char *ct = strstr(contp, ";type=");
+
+ info[i].option = CURLFORM_COPYNAME;
+ info[i].value = name;
+ i++;
+
+ if(ct) {
+ info[i].option = CURLFORM_CONTENTTYPE;
+ info[i].value = &ct[6];
+ i++;
+ ct[0]=0; /* zero terminate here */
+ }
+
if( contp[0]=='<' ) {
+ info[i].option = CURLFORM_FILECONTENT;
+ info[i].value = contp+1;
+ i++;
+ info[i].option = CURLFORM_END;
+
if (curl_formadd(httppost, last_post,
- CURLFORM_COPYNAME, name,
- CURLFORM_FILECONTENT, contp+1, CURLFORM_END) != 0) {
- fprintf(stderr, "curl_formadd failed!\n");
+ CURLFORM_ARRAY, info, CURLFORM_END ) != 0) {
+ fprintf(stderr, "curl_formadd failed, possibly the file %s is bad!\n",
+ contp+1);
free(contents);
return 6;
}
}
else {
+ info[i].option = CURLFORM_COPYCONTENTS;
+ info[i].value = contp;
+ i++;
+ info[i].option = CURLFORM_END;
if (curl_formadd(httppost, last_post,
- CURLFORM_COPYNAME, name,
- CURLFORM_COPYCONTENTS, contp, CURLFORM_END) != 0) {
+ CURLFORM_ARRAY, info, CURLFORM_END) != 0) {
fprintf(stderr, "curl_formadd failed!\n");
free(contents);
return 7;