tool_operate: keep the filename for upload globbing

Follow-up to 19695e815c

Verify with test 2012 and 2013

Closes #21401
This commit is contained in:
Daniel Stenberg 2026-04-21 17:14:51 +02:00
parent 779bba2f3f
commit dcf535629b
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
4 changed files with 189 additions and 3 deletions

View 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);

View 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 \

95
tests/data/test2012 Normal file
View file

@ -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>

90
tests/data/test2013 Normal file
View file

@ -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>