summaryrefslogtreecommitdiff
path: root/lib/setopt.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-06-24 15:48:39 +0200
committerDaniel Stenberg <daniel@haxx.se>2020-06-24 15:48:39 +0200
commit62241fa99f73d4d99d1af50c402a67701e0e5d79 (patch)
treeae452d7b7d688816f117561a0b82a609a6594c35 /lib/setopt.c
parent7fb33ee871a04d2e4f6ffedba0808635efb1ef53 (diff)
downloadcurl-62241fa99f73d4d99d1af50c402a67701e0e5d79.tar.gz
setopt: make INFILESIZE and POSTFIELDSIZE do the same thingbagder/filesize-unite
They're both used to set the size of the request body so let's treat them as identical internally.
Diffstat (limited to 'lib/setopt.c')
-rw-r--r--lib/setopt.c44
1 files changed, 13 insertions, 31 deletions
diff --git a/lib/setopt.c b/lib/setopt.c
index 90edf6aa7..82233a41b 100644
--- a/lib/setopt.c
+++ b/lib/setopt.c
@@ -534,16 +534,16 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
*/
argptr = va_arg(param, char *);
- if(!argptr || data->set.postfieldsize == -1)
+ if(!argptr || data->set.filesize == -1)
result = Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], argptr);
else {
/*
* Check that requested length does not overflow the size_t type.
*/
- if((data->set.postfieldsize < 0) ||
+ if((data->set.filesize < 0) ||
((sizeof(curl_off_t) != sizeof(size_t)) &&
- (data->set.postfieldsize > (curl_off_t)((size_t)-1))))
+ (data->set.filesize > (curl_off_t)((size_t)-1))))
result = CURLE_OUT_OF_MEMORY;
else {
char *p;
@@ -555,14 +555,14 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
to mark that postfields is used rather than read function or
form data.
*/
- p = malloc((size_t)(data->set.postfieldsize?
- data->set.postfieldsize:1));
+ p = malloc((size_t)(data->set.filesize?
+ data->set.filesize:1));
if(!p)
result = CURLE_OUT_OF_MEMORY;
else {
- if(data->set.postfieldsize)
- memcpy(p, argptr, (size_t)data->set.postfieldsize);
+ if(data->set.filesize)
+ memcpy(p, argptr, (size_t)data->set.filesize);
data->set.str[STRING_COPYPOSTFIELDS] = p;
}
@@ -583,6 +583,7 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
data->set.method = HTTPREQ_POST;
break;
+ case CURLOPT_INFILESIZE:
case CURLOPT_POSTFIELDSIZE:
/*
* The size of the POSTFIELD data to prevent libcurl to do strlen() to
@@ -592,16 +593,17 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
if(bigsize < -1)
return CURLE_BAD_FUNCTION_ARGUMENT;
- if(data->set.postfieldsize < bigsize &&
+ if(data->set.filesize < bigsize &&
data->set.postfields == data->set.str[STRING_COPYPOSTFIELDS]) {
/* Previous CURLOPT_COPYPOSTFIELDS is no longer valid. */
(void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
data->set.postfields = NULL;
}
- data->set.postfieldsize = bigsize;
+ data->set.filesize = bigsize;
break;
+ case CURLOPT_INFILESIZE_LARGE:
case CURLOPT_POSTFIELDSIZE_LARGE:
/*
* The size of the POSTFIELD data to prevent libcurl to do strlen() to
@@ -611,14 +613,14 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
if(bigsize < -1)
return CURLE_BAD_FUNCTION_ARGUMENT;
- if(data->set.postfieldsize < bigsize &&
+ if(data->set.filesize < bigsize &&
data->set.postfields == data->set.str[STRING_COPYPOSTFIELDS]) {
/* Previous CURLOPT_COPYPOSTFIELDS is no longer valid. */
(void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
data->set.postfields = NULL;
}
- data->set.postfieldsize = bigsize;
+ data->set.filesize = bigsize;
break;
case CURLOPT_HTTPPOST:
@@ -1243,26 +1245,6 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
*/
data->set.in_set = va_arg(param, void *);
break;
- case CURLOPT_INFILESIZE:
- /*
- * If known, this should inform curl about the file size of the
- * to-be-uploaded file.
- */
- arg = va_arg(param, long);
- if(arg < -1)
- return CURLE_BAD_FUNCTION_ARGUMENT;
- data->set.filesize = arg;
- break;
- case CURLOPT_INFILESIZE_LARGE:
- /*
- * If known, this should inform curl about the file size of the
- * to-be-uploaded file.
- */
- bigsize = va_arg(param, curl_off_t);
- if(bigsize < -1)
- return CURLE_BAD_FUNCTION_ARGUMENT;
- data->set.filesize = bigsize;
- break;
case CURLOPT_LOW_SPEED_LIMIT:
/*
* The low speed limit that if transfers are below this for