write-out: make %header{} able to output *all* occurances of a header

By appending `:all:[separator]` to the header name. The `[separator]` string
is output between each header value if there are more than one to output.

Test 764 and 765 verify

Idea-by: kapsiR on github
Ref: #18449
Closes #18491
This commit is contained in:
Daniel Stenberg 2025-09-08 00:18:52 +02:00
parent 522c991336
commit 6abe788bb8
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
5 changed files with 249 additions and 17 deletions

View file

@ -109,7 +109,7 @@ test727 test728 test729 test730 test731 test732 test733 test734 test735 \
test736 test737 test738 test739 test740 test741 test742 test743 test744 \
test745 test746 test747 test748 test749 test750 test751 test752 test753 \
test754 test755 test756 test757 test758 test759 test760 test761 test762 \
test763 \
test763 test764 test765 \
\
test780 test781 test782 test783 test784 test785 test786 test787 test788 \
test789 test790 test791 test792 test793 test794 test795 test796 test797 \

67
tests/data/test764 Normal file
View file

@ -0,0 +1,67 @@
<testcase>
<info>
<keywords>
HTTP
HTTP GET
-w
%header
</keywords>
</info>
#
# Server-side
<reply>
<data nocheck="yes">
HTTP/1.1 301 Redirect
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
This: one
This: two
Content-Length: 6
Location: %TESTNUMBER0002
Content-Type: text/html
Funny-head: yesyes
-foo-
</data>
<data2 nocheck="yes">
HTTP/1.1 200 Not a redirect
Accept-Ranges: bytes
This: three
This: four
Content-Length: 6
Funny-head: yesyes
-foo-
</data2>
</reply>
#
# Client-side
<client>
<features>
headers-api
</features>
<server>
http
</server>
<name>
-w with multiple header output
</name>
<command option="no-output">
http://%HOSTIP:%HTTPPORT/%TESTNUMBER -L -w '%header{this:all:***}\n' -o %LOGDIR/%TESTNUMBER.out
</command>
</client>
#
# Verify data after the test has been "shot"
<verify>
<stdout mode="text">
one***two***three***four
</stdout>
</verify>
</testcase>

67
tests/data/test765 Normal file
View file

@ -0,0 +1,67 @@
<testcase>
<info>
<keywords>
HTTP
HTTP GET
-w
%header
</keywords>
</info>
#
# Server-side
<reply>
<data nocheck="yes">
HTTP/1.1 301 Redirect
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
This: one
This: two
Content-Length: 6
Location: %TESTNUMBER0002
Content-Type: text/html
Funny-head: yesyes
-foo-
</data>
<data2 nocheck="yes">
HTTP/1.1 200 Not a redirect
Accept-Ranges: bytes
This: three
This: four
Content-Length: 6
Funny-head: yesyes
-foo-
</data2>
</reply>
#
# Client-side
<client>
<features>
headers-api
</features>
<server>
http
</server>
<name>
-w with multiple header output using } in separator
</name>
<command option="no-output">
http://%HOSTIP:%HTTPPORT/%TESTNUMBER -L -w '%header{this:all:-{\}-}\n' -o %LOGDIR/%TESTNUMBER.out
</command>
</client>
#
# Verify data after the test has been "shot"
<verify>
<stdout mode="text">
one-{}-two-{}-three-{}-four
</stdout>
</verify>
</testcase>