1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-22 08:08:50 -05:00

This makes formposting with a specified file missing fail. curl_easy_perform

will then return CURLE_READ_ERROR.
This commit is contained in:
Daniel Stenberg 2002-04-15 11:19:03 +00:00
parent 9549cfde02
commit 95f78080ab
3 changed files with 30 additions and 14 deletions

View File

@ -1044,22 +1044,24 @@ void curl_formfree(struct curl_httppost *form)
} while((form=next)); /* continue */ } while((form=next)); /* continue */
} }
struct FormData *Curl_getFormData(struct curl_httppost *post, CURLcode Curl_getFormData(struct FormData **finalform,
struct curl_httppost *post,
int *sizep) int *sizep)
{ {
struct FormData *form = NULL; struct FormData *form = NULL;
struct FormData *firstform; struct FormData *firstform;
struct curl_httppost *file; struct curl_httppost *file;
CURLcode result = CURLE_OK;
int size =0; int size =0;
char *boundary; char *boundary;
char *fileboundary=NULL; char *fileboundary=NULL;
struct curl_slist* curList; struct curl_slist* curList;
*finalform=NULL; /* default form is empty */
if(!post) if(!post)
return NULL; /* no input => no output! */ return result; /* no input => no output! */
boundary = Curl_FormBoundary(); boundary = Curl_FormBoundary();
@ -1166,17 +1168,21 @@ struct FormData *Curl_getFormData(struct curl_httppost *post,
/*VMS?? Stream files are OK, as are FIXED & VAR files WITHOUT implied CC */ /*VMS?? Stream files are OK, as are FIXED & VAR files WITHOUT implied CC */
/*VMS?? For implied CC, every record needs to have a \n appended & 1 added to SIZE */ /*VMS?? For implied CC, every record needs to have a \n appended & 1 added to SIZE */
if(fileread) { if(fileread) {
while((nread = fread(buffer, 1, 1024, fileread))) { while((nread = fread(buffer, 1, 1024, fileread)))
size += AddFormData(&form, size += AddFormData(&form, buffer, nread);
buffer,
nread);
}
if(fileread != stdin) if(fileread != stdin)
fclose(fileread); fclose(fileread);
} }
else { else {
#if 0
/* File wasn't found, add a nothing field! */ /* File wasn't found, add a nothing field! */
size += AddFormData(&form, "", 0); size += AddFormData(&form, "", 0);
#endif
Curl_formclean(firstform);
free(boundary);
*finalform = NULL;
return CURLE_READ_ERROR;
} }
} }
else { else {
@ -1205,7 +1211,9 @@ struct FormData *Curl_getFormData(struct curl_httppost *post,
free(boundary); free(boundary);
return firstform; *finalform=firstform;
return result;
} }
int Curl_FormInit(struct Form *form, struct FormData *formdata ) int Curl_FormInit(struct Form *form, struct FormData *formdata )

View File

@ -53,7 +53,9 @@ typedef struct FormInfo {
int Curl_FormInit(struct Form *form, struct FormData *formdata ); int Curl_FormInit(struct Form *form, struct FormData *formdata );
struct FormData *Curl_getFormData(struct HttpPost *post, CURLcode
Curl_getFormData(struct FormData **,
struct HttpPost *post,
int *size); int *size);
/* fread() emulation */ /* fread() emulation */

View File

@ -562,7 +562,13 @@ CURLcode Curl_http(struct connectdata *conn)
if(HTTPREQ_POST_FORM == data->set.httpreq) { if(HTTPREQ_POST_FORM == data->set.httpreq) {
/* 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 */
http->sendit = Curl_getFormData(data->set.httppost, &http->postsize); result = Curl_getFormData(&http->sendit, data->set.httppost,
&http->postsize);
if(CURLE_OK != result) {
/* Curl_getFormData() doesn't use failf() */
failf(data, "failed creating formpost data");
return result;
}
} }
if(!checkheaders(data, "Host:")) { if(!checkheaders(data, "Host:")) {