]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool_operate: keep the filename for upload globbing
authorDaniel Stenberg <daniel@haxx.se>
Tue, 21 Apr 2026 15:14:51 +0000 (17:14 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 21 Apr 2026 21:11:42 +0000 (23:11 +0200)
Follow-up to 19695e815c51f8830fc54255

Verify with test 2012 and 2013

Closes #21401

src/tool_operate.c
tests/data/Makefile.am
tests/data/test2012 [new file with mode: 0644]
tests/data/test2013 [new file with mode: 0644]

index 4969c4193195f770b7c0752d0888afbfbfb5150a..84da414ada1fbc549ed856fee16f1ba2ebc8c7c2 100644 (file)
@@ -1076,8 +1076,9 @@ static CURLcode setup_outfile(struct OperationConfig *config,
     }
   }
   else {
-    per->outfile = u->outfile;
-    u->outfile = NULL;
+    per->outfile = curlx_strdup(u->outfile);
+    if(!per->outfile)
+      return CURLE_OUT_OF_MEMORY;
   }
 
   DEBUGASSERT(per->outfile);
index 2c25c0b1d24c0a9acee6cc054558f33530aa2979..dc0d8311ec5ab8cffe7f67393c004a4b401f1282 100644 (file)
@@ -245,7 +245,7 @@ test1970 test1971 test1972 test1973 test1974 test1975 test1976 test1977 \
 test1978 test1979 test1980 test1981 test1982 test1983 test1984 \
 \
 test2000 test2001 test2002 test2003 test2004 test2005 test2006 test2007 \
-test2008 test2009 test2010 test2011 \
+test2008 test2009 test2010 test2011 test2012 test2013 \
 \
                                                                test2023 \
 test2024 test2025 test2026 test2027 test2028 test2029 test2030 test2031 \
diff --git a/tests/data/test2012 b/tests/data/test2012
new file mode 100644 (file)
index 0000000..ecc6489
--- /dev/null
@@ -0,0 +1,95 @@
+<?xml version="1.0" encoding="US-ASCII"?>
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP PUT
+</keywords>
+</info>
+
+# Server-side
+<reply>
+<data crlf="headers" nocheck="yes">
+HTTP/1.1 200 OK
+Date: Tue, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Accept-Ranges: bytes
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+
+-foo-
+</data>
+<data2 crlf="headers" nocheck="yes">
+HTTP/1.1 200 the second one
+Date: Tue, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Accept-Ranges: bytes
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+
+again
+</data2>
+</reply>
+
+# Client-side
+<client>
+<server>
+http
+</server>
+<name>
+load URLs from a file, upload with a glob
+</name>
+<command option="no-output">
+-T '%LOGDIR/upload{1,2}' --url @%LOGDIR/urls --silent --output=%LOGDIR/first-out --output=%LOGDIR/second-out
+</command>
+
+<file name="%LOGDIR/upload1">
+first!
+</file>
+
+<file2 name="%LOGDIR/upload2">
+second
+</file2>
+
+<file3 name="%LOGDIR/urls">
+http://%HOSTIP:%HTTPPORT/%TESTNUMBER
+http://%HOSTIP:%HTTPPORT/%TESTNUMBER0002
+</file3>
+
+</client>
+
+# Verify data after the test has been "shot"
+<verify>
+<protocol crlf="headers">
+PUT /%TESTNUMBER HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+Content-Length: 7
+
+first!
+PUT /%TESTNUMBER HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+Content-Length: 7
+
+second
+GET /%TESTNUMBER0002 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+
+GET /%TESTNUMBER0002 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+
+</protocol>
+<stdout>
+%EMPTY
+</stdout>
+</verify>
+</testcase>
diff --git a/tests/data/test2013 b/tests/data/test2013
new file mode 100644 (file)
index 0000000..b5dfa10
--- /dev/null
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="US-ASCII"?>
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP PUT
+</keywords>
+</info>
+
+# Server-side
+<reply>
+<data crlf="headers" nocheck="yes">
+HTTP/1.1 200 OK
+Date: Tue, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Accept-Ranges: bytes
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+
+-foo-
+</data>
+<data2 crlf="headers" nocheck="yes">
+HTTP/1.1 200 the second one
+Date: Tue, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Accept-Ranges: bytes
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+
+again
+</data2>
+</reply>
+
+# Client-side
+<client>
+<server>
+http
+</server>
+<name>
+upload with a glob
+</name>
+<command option="no-output">
+-T '%LOGDIR/upload{1,2}' http://%HOSTIP:%HTTPPORT/%TESTNUMBER http://%HOSTIP:%HTTPPORT/%TESTNUMBER0002 --silent --output=%LOGDIR/first-out --output=%LOGDIR/second-out
+</command>
+
+<file name="%LOGDIR/upload1">
+first!
+</file>
+
+<file2 name="%LOGDIR/upload2">
+second
+</file2>
+
+</client>
+
+# Verify data after the test has been "shot"
+<verify>
+<protocol crlf="headers">
+PUT /%TESTNUMBER HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+Content-Length: 7
+
+first!
+PUT /%TESTNUMBER HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+Content-Length: 7
+
+second
+GET /%TESTNUMBER0002 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+
+GET /%TESTNUMBER0002 HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+
+</protocol>
+<stdout>
+%EMPTY
+</stdout>
+</verify>
+</testcase>