From: Daniel Stenberg Date: Tue, 30 May 2023 12:45:47 +0000 (+0200) Subject: test447: test PUTting a file that grows X-Git-Tag: curl-8_2_0~168 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bfa7006424c196d45da7c7224f539ff56f9e5033;p=thirdparty%2Fcurl.git test447: test PUTting a file that grows ... and have curl trim the end when it reaches the expected total amount of bytes instead of over-sending. Reported-by: JustAnotherArchivist on github Closes #11223 --- diff --git a/src/tool_operate.c b/src/tool_operate.c index 1c49c1e4ef..16ad0665ee 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -319,6 +319,17 @@ static CURLcode pre_transfer(struct GlobalConfig *global, if(S_ISREG(fileinfo.st_mode)) uploadfilesize = fileinfo.st_size; +#ifdef DEBUGBUILD + /* allow dedicated test cases to override */ + { + char *ev = getenv("CURL_UPLOAD_SIZE"); + if(ev) { + int sz = atoi(ev); + uploadfilesize = (curl_off_t)sz; + } + } +#endif + if(uploadfilesize != -1) { struct OperationConfig *config = per->config; /* for the macro below */ #ifdef CURL_DISABLE_LIBCURL_OPTION diff --git a/tests/data/Makefile.inc b/tests/data/Makefile.inc index 217ada761e..f054175edb 100644 --- a/tests/data/Makefile.inc +++ b/tests/data/Makefile.inc @@ -72,7 +72,7 @@ test417 test418 test419 test420 test421 test422 test423 test424 test425 \ test426 \ test430 test431 test432 test433 test434 test435 test436 \ \ -test440 test441 test442 test443 test444 test445 test446 \ +test440 test441 test442 test443 test444 test445 test446 test447 \ \ test490 test491 test492 test493 test494 test495 test496 \ \ diff --git a/tests/data/test447 b/tests/data/test447 new file mode 100644 index 0000000000..76614bab67 --- /dev/null +++ b/tests/data/test447 @@ -0,0 +1,65 @@ + + + +HTTP +HTTP PUT +growing file + + + +# +# Server-side + + +HTTP/1.1 200 OK +Date: Tue, 09 Nov 2010 14:49:00 GMT +Server: test-server/fake +Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT +ETag: "21025-dc7-39462498" +Accept-Ranges: bytes +Content-Length: 6 +Connection: close +Content-Type: text/html +Funny-head: yesyes + +-foo- + + + +# +# Client-side + + +debug + + +http + + +HTTP PUT with growing file + + +CURL_UPLOAD_SIZE=498 + + +http://%HOSTIP:%HTTPPORT/%TESTNUMBER -T log/%TESTNUMBER + + +%repeat[100 x hello]% + + + +# +# Verify data after the test has been "shot" + + +PUT /%TESTNUMBER HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +User-Agent: curl/%VERSION +Accept: */* +Content-Length: 498 + +%repeat[99 x hello]%hel + + +