formdata: provide error message
When failing to build form post due to an error, the code now does a proper failf(). Previously libcurl would report an error like "failed creating formpost data" when a file wasn't possible to open which was not easy for users to figure out. I also lower cased a function name to be named more curl-style and removed some unnecessary code.
This commit is contained in:
18
lib/http.c
18
lib/http.c
@@ -2375,19 +2375,15 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
|
||||
#endif /* CURL_DISABLE_PROXY */
|
||||
|
||||
if(HTTPREQ_POST_FORM == httpreq) {
|
||||
/* 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 */
|
||||
result = Curl_getFormData(&http->sendit, data->set.httppost,
|
||||
Curl_checkheaders(data, "Content-Type:"),
|
||||
&http->postsize);
|
||||
if(CURLE_OK != result) {
|
||||
/* Curl_getFormData() doesn't use failf() */
|
||||
failf(data, "failed creating formpost data");
|
||||
return result;
|
||||
}
|
||||
/* we must build the whole post sequence first, so that we have a size of
|
||||
the whole transfer before we start to send it */
|
||||
result = Curl_getformdata(data, &http->sendit, data->set.httppost,
|
||||
Curl_checkheaders(data, "Content-Type:"),
|
||||
&http->postsize);
|
||||
if(result)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
http->p_accept = Curl_checkheaders(data, "Accept:")?NULL:"Accept: */*\r\n";
|
||||
|
||||
if(( (HTTPREQ_POST == httpreq) ||
|
||||
|
Reference in New Issue
Block a user