From: Daniel Stenberg Date: Sat, 21 Dec 2024 10:45:28 +0000 (+0100) Subject: curl: make --etag-save acknowledge --create-dirs X-Git-Tag: curl-8_12_0~297 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31c6b50cb274db4513e52991b74b09e6ee2cdaa2;p=thirdparty%2Fcurl.git curl: make --etag-save acknowledge --create-dirs Add test 693 to verify Fixes #15730 Suggested-by: Tamir Duberstein Closes #15732 --- diff --git a/docs/cmdline-opts/etag-save.md b/docs/cmdline-opts/etag-save.md index c81773b6e2..237b5dc548 100644 --- a/docs/cmdline-opts/etag-save.md +++ b/docs/cmdline-opts/etag-save.md @@ -20,3 +20,6 @@ Save an HTTP ETag to the specified file. An ETag is a caching related header, usually returned in a response. Use this option with a single URL only. If no ETag is sent by the server, an empty file is created. + +Starting in curl 8.12.0, using the --create-dirs option can also create +missing directory components for the path provided in --etag-save. diff --git a/src/tool_operate.c b/src/tool_operate.c index a2ceeac3dd..14b559b656 100644 --- a/src/tool_operate.c +++ b/src/tool_operate.c @@ -1976,6 +1976,12 @@ static CURLcode single_transfer(struct GlobalConfig *global, } if(config->etag_save_file) { + if(config->create_dirs) { + result = create_dir_hierarchy(config->etag_save_file, global); + if(result) + break; + } + /* open file for output: */ if(strcmp(config->etag_save_file, "-")) { FILE *newfile = fopen(config->etag_save_file, "ab"); diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 6d4ddd29ae..5bef667fa1 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -101,7 +101,7 @@ test652 test653 test654 test655 test656 test658 test659 test660 test661 \ test662 test663 test664 test665 test666 test667 test668 test669 test670 \ test671 test672 test673 test674 test675 test676 test677 test678 test679 \ test680 test681 test682 test683 test684 test685 test686 test687 test688 \ -test689 test690 test691 test692 \ +test689 test690 test691 test692 test693 \ \ test700 test701 test702 test703 test704 test705 test706 test707 test708 \ test709 test710 test711 test712 test713 test714 test715 test716 test717 \ diff --git a/tests/data/test693 b/tests/data/test693 new file mode 100644 index 0000000000..533ce80311 --- /dev/null +++ b/tests/data/test693 @@ -0,0 +1,62 @@ + + + +HTTP +HTTP GET +etags + + +# +# Server-side + + +HTTP/1.1 200 funky chunky! +Server: fakeit/0.9 fakeitbad/1.0 +Transfer-Encoding: chunked +Trailer: chunky-trailer +Connection: mooo +ETag: W/"asdf" + +40 +aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa +30 +bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb +21;heresatest=moooo +cccccccccccccccccccccccccccccccc + +0 +chunky-trailer: header data + + + + +# +# Client-side + + +http + + +--etag-save with --create-dirs + + +http://%HOSTIP:%HTTPPORT/%TESTNUMBER --etag-save %LOGDIR/moo/boo/etag%TESTNUMBER --create-dirs + + + +# +# Verify data after the test has been "shot" + + +GET /%TESTNUMBER HTTP/1.1 +Host: %HOSTIP:%HTTPPORT +User-Agent: curl/%VERSION +Accept: */* + + + +W/"asdf" + + + +