Yves Lejeune fixed so that replacing Content-Type: when doing multipart
formposts work exactly the way you want it (and the way you'd assume it works)
This commit is contained in:
parent
e6ea8f1199
commit
a88deadd6f
5
CHANGES
5
CHANGES
@ -6,6 +6,11 @@
|
|||||||
|
|
||||||
Changelog
|
Changelog
|
||||||
|
|
||||||
|
Daniel (28 July 2006)
|
||||||
|
- Yves Lejeune fixed so that replacing Content-Type: when doing multipart
|
||||||
|
formposts work exactly the way you want it (and the way you'd assume it
|
||||||
|
works).
|
||||||
|
|
||||||
Daniel (27 July 2006)
|
Daniel (27 July 2006)
|
||||||
- David McCreedy added --ftp-ssl-reqd which makes curl *require* SSL for both
|
- David McCreedy added --ftp-ssl-reqd which makes curl *require* SSL for both
|
||||||
control and data connection, as the existing --ftp-ssl option only requests
|
control and data connection, as the existing --ftp-ssl option only requests
|
||||||
|
@ -24,6 +24,7 @@ This release includes the following changes:
|
|||||||
|
|
||||||
This release includes the following bugfixes:
|
This release includes the following bugfixes:
|
||||||
|
|
||||||
|
o changing Content-Type when doing formposts
|
||||||
o added CURL_EXTERN to a few recent multi functions that lacked them
|
o added CURL_EXTERN to a few recent multi functions that lacked them
|
||||||
o splay-tree related problems for internal expire time handling
|
o splay-tree related problems for internal expire time handling
|
||||||
o FTP ASCII CRLF counter reset
|
o FTP ASCII CRLF counter reset
|
||||||
@ -48,6 +49,6 @@ advice from friends like these:
|
|||||||
|
|
||||||
Dan Fandrich, Peter Silva, Arve Knudsen, Michael Wallner, Toshiyuki Maezawa,
|
Dan Fandrich, Peter Silva, Arve Knudsen, Michael Wallner, Toshiyuki Maezawa,
|
||||||
Ingmar Runge, Ates Goral, David McCreedy, Jari Sundell, Georg Horn,
|
Ingmar Runge, Ates Goral, David McCreedy, Jari Sundell, Georg Horn,
|
||||||
Gisle Vanem, Yang Tse, Michael Jerris, Dan Nelson
|
Gisle Vanem, Yang Tse, Michael Jerris, Dan Nelson, Yves Lejeune
|
||||||
|
|
||||||
Thanks! (and sorry if I forgot to mention someone)
|
Thanks! (and sorry if I forgot to mention someone)
|
||||||
|
@ -899,9 +899,9 @@ int curl_formget(struct curl_httppost *form, void *arg,
|
|||||||
curl_off_t size;
|
curl_off_t size;
|
||||||
struct FormData *data, *ptr;
|
struct FormData *data, *ptr;
|
||||||
|
|
||||||
if ((rc = Curl_getFormData(&data, form, &size)) != CURLE_OK) {
|
rc = Curl_getFormData(&data, form, NULL, &size);
|
||||||
|
if (rc != CURLE_OK)
|
||||||
return (int)rc;
|
return (int)rc;
|
||||||
}
|
|
||||||
|
|
||||||
for (ptr = data; ptr; ptr = ptr->next) {
|
for (ptr = data; ptr; ptr = ptr->next) {
|
||||||
if (ptr->type == FORM_FILE) {
|
if (ptr->type == FORM_FILE) {
|
||||||
@ -1031,10 +1031,13 @@ static char *strippath(char *fullfile)
|
|||||||
* (possibly huge) multipart formdata. The input list is in 'post', while the
|
* (possibly huge) multipart formdata. The input list is in 'post', while the
|
||||||
* output resulting linked lists gets stored in '*finalform'. *sizep will get
|
* output resulting linked lists gets stored in '*finalform'. *sizep will get
|
||||||
* the total size of the whole POST.
|
* 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,
|
CURLcode Curl_getFormData(struct FormData **finalform,
|
||||||
struct curl_httppost *post,
|
struct curl_httppost *post,
|
||||||
|
const char *custom_content_type,
|
||||||
curl_off_t *sizep)
|
curl_off_t *sizep)
|
||||||
{
|
{
|
||||||
struct FormData *form = NULL;
|
struct FormData *form = NULL;
|
||||||
@ -1058,9 +1061,11 @@ CURLcode Curl_getFormData(struct FormData **finalform,
|
|||||||
|
|
||||||
/* Make the first line of the output */
|
/* Make the first line of the output */
|
||||||
result = AddFormDataf(&form, NULL,
|
result = AddFormDataf(&form, NULL,
|
||||||
"Content-Type: multipart/form-data;"
|
"%s; boundary=%s\r\n",
|
||||||
" boundary=%s\r\n",
|
custom_content_type?custom_content_type:
|
||||||
|
"Content-Type: multipart/form-data",
|
||||||
boundary);
|
boundary);
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
free(boundary);
|
free(boundary);
|
||||||
return result;
|
return result;
|
||||||
@ -1083,6 +1088,10 @@ CURLcode Curl_getFormData(struct FormData **finalform,
|
|||||||
if (result)
|
if (result)
|
||||||
break;
|
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,
|
result = AddFormDataf(&form, &size,
|
||||||
"Content-Disposition: form-data; name=\"");
|
"Content-Disposition: form-data; name=\"");
|
||||||
if (result)
|
if (result)
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
@ -69,6 +69,7 @@ int Curl_FormInit(struct Form *form, struct FormData *formdata );
|
|||||||
CURLcode
|
CURLcode
|
||||||
Curl_getFormData(struct FormData **,
|
Curl_getFormData(struct FormData **,
|
||||||
struct curl_httppost *post,
|
struct curl_httppost *post,
|
||||||
|
const char *custom_contenttype,
|
||||||
curl_off_t *size);
|
curl_off_t *size);
|
||||||
|
|
||||||
/* fread() emulation */
|
/* fread() emulation */
|
||||||
|
15
lib/http.c
15
lib/http.c
@ -1554,8 +1554,12 @@ static CURLcode add_custom_headers(struct connectdata *conn,
|
|||||||
header as that will produce *two* in the same request! */
|
header as that will produce *two* in the same request! */
|
||||||
curl_strnequal("Host:", headers->data, 5))
|
curl_strnequal("Host:", headers->data, 5))
|
||||||
;
|
;
|
||||||
|
else if(conn->data->set.httpreq == HTTPREQ_POST_FORM &&
|
||||||
|
/* this header (extended by formdata.c) is sent later */
|
||||||
|
curl_strnequal("Content-Type:", headers->data,
|
||||||
|
strlen("Content-Type:")))
|
||||||
|
;
|
||||||
else {
|
else {
|
||||||
|
|
||||||
result = add_bufferf(req_buffer, "%s\r\n", headers->data);
|
result = add_bufferf(req_buffer, "%s\r\n", headers->data);
|
||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
@ -1809,6 +1813,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
|||||||
/* we must build the whole darned post sequence first, so that we have
|
/* we must build the whole darned post sequence first, so that we have
|
||||||
a size of the whole shebang before we start to send it */
|
a size of the whole shebang before we start to send it */
|
||||||
result = Curl_getFormData(&http->sendit, data->set.httppost,
|
result = Curl_getFormData(&http->sendit, data->set.httppost,
|
||||||
|
checkheaders(data, "Content-Type:"),
|
||||||
&http->postsize);
|
&http->postsize);
|
||||||
if(CURLE_OK != result) {
|
if(CURLE_OK != result) {
|
||||||
/* Curl_getFormData() doesn't use failf() */
|
/* Curl_getFormData() doesn't use failf() */
|
||||||
@ -2134,12 +2139,9 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
|||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
if(!checkheaders(data, "Content-Type:")) {
|
{
|
||||||
/* Get Content-Type: line from Curl_formpostheader.
|
|
||||||
|
|
||||||
The Content-Type header line also contains the MIME boundary
|
/* Get Content-Type: line from Curl_formpostheader.
|
||||||
string etc why disabling this header is likely to not make things
|
|
||||||
work, but we support disabling it anyway.
|
|
||||||
*/
|
*/
|
||||||
char *contentType;
|
char *contentType;
|
||||||
size_t linelength=0;
|
size_t linelength=0;
|
||||||
@ -2149,6 +2151,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
|||||||
failf(data, "Could not get Content-Type header line!");
|
failf(data, "Could not get Content-Type header line!");
|
||||||
return CURLE_HTTP_POST_ERROR;
|
return CURLE_HTTP_POST_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = add_buffer(req_buffer, contentType, linelength);
|
result = add_buffer(req_buffer, contentType, linelength);
|
||||||
if(result)
|
if(result)
|
||||||
return result;
|
return result;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user