]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool_operate: let --create-dirs work for --dump-header as well
authorDaniel Stenberg <daniel@haxx.se>
Thu, 19 Sep 2024 08:43:58 +0000 (10:43 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 22 Sep 2024 19:27:29 +0000 (21:27 +0200)
Add test 3011 to verify

Proposed-by: Montg0mery on github
Fixes #14941
Closes #14965

docs/cmdline-opts/dump-header.md
src/tool_operate.c
tests/data/Makefile.am
tests/data/test3031 [new file with mode: 0644]

index 81da38c4091acaf0d8dc073956fab82cb82293df..bdb0e874e35a3d1993b8761aa463f67969adb34f 100644 (file)
@@ -28,5 +28,8 @@ writes the output to stderr.
 When used in FTP, the FTP server response lines are considered being "headers"
 and thus are saved there.
 
+Starting in curl 8.11.0, using the --create-dirs option can also create
+missing directory components for the path provided in --dump-header.
+
 Having multiple transfers in one set of operations (i.e. the URLs in one
 --next clause), appends them to the same file, separated by a blank line.
index b49e9fd06f86496669463defc2924ec0cc554f13..90b6efdadec56f71119a77822cfe000a3fa80f59 100644 (file)
@@ -1090,6 +1090,12 @@ static CURLcode single_transfer(struct GlobalConfig *global,
              * OperationConfig, so that it does not need to be opened/closed
              * for every transfer.
              */
+            if(config->create_dirs) {
+              result = create_dir_hierarchy(config->headerfile, global);
+              /* create_dir_hierarchy shows error upon CURLE_WRITE_ERROR */
+              if(result)
+                break;
+            }
             if(!per->prev || per->prev->config != config) {
               newfile = fopen(config->headerfile, "wb");
               if(newfile)
index d6bd237c28d8d1b8aab8afd4155e2b055fa28f21..f5f903e869adc7ae3993602d73fd2f07a5253c74 100644 (file)
@@ -264,7 +264,7 @@ test2600 test2601 test2602 test2603 test2604 \
 test3000 test3001 test3002 test3003 test3004 test3005 test3006 test3007 \
 test3008 test3009 test3010 test3011 test3012 test3013 test3014 test3015 \
 test3016 test3017 test3018 test3019 test3020 test3021 test3022 test3023 \
-test3024 test3025 test3026 test3027 test3028 test3029 test3030 \
+test3024 test3025 test3026 test3027 test3028 test3029 test3030 test3031 \
 \
 test3100 test3101 test3102 test3103 \
 test3200 \
diff --git a/tests/data/test3031 b/tests/data/test3031
new file mode 100644 (file)
index 0000000..58edc37
--- /dev/null
@@ -0,0 +1,67 @@
+<testcase>
+<info>
+<keywords>
+--dump-header
+</keywords>
+</info>
+#
+# Server-side
+<reply>
+<data nocheck="yes" crlf="yes">
+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-
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+<server>
+http
+</server>
+<features>
+http
+</features>
+<name>
+--output-dir with --create-dirs
+</name>
+<command>
+http://%HOSTIP:%HTTPPORT/this/is/the/%TESTNUMBER --dump-header %PWD/%LOGDIR/tmp/out.txt --create-dirs
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<protocol>
+GET /this/is/the/%TESTNUMBER HTTP/1.1\r
+Host: %HOSTIP:%HTTPPORT\r
+User-Agent: curl/%VERSION\r
+Accept: */*\r
+\r
+</protocol>
+<file name="%LOGDIR/tmp/out.txt" crlf="yes">
+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
+
+</file>
+</verify>
+</testcase>