Similar to how --trace and --trace-ascii already do it.
Added test 1489 to verify
Closes #13992
# `--dump-header`
Write the received protocol headers to the specified file. If no headers are
-received, the use of this option creates an empty file. Specify `-` as file
-name (a single minus) to have it written to stdout.
+received, the use of this option creates an empty file. Specify `-` as
+filename (a single minus) to have it written to stdout.
+
+Starting in curl 8.10.0, specify `%` (a single percent sign) as filename
+writes the output to stderr.
When used in FTP, the FTP server response lines are considered being "headers"
and thus are saved there.
/* Single header file for all URLs */
if(config->headerfile) {
/* open file for output: */
- if(strcmp(config->headerfile, "-")) {
+ if(!strcmp(config->headerfile, "%")) {
+ heads->stream = stderr;
+ /* use binary mode for protocol header output */
+ set_binmode(heads->stream);
+ }
+ else if(strcmp(config->headerfile, "-")) {
FILE *newfile;
/*
test1463 test1464 test1465 test1466 test1467 test1468 test1469 test1470 \
test1471 test1472 test1473 test1474 test1475 test1476 test1477 test1478 \
test1479 test1480 test1481 test1482 test1483 test1484 test1485 test1486 \
-test1487 test1488 \
+test1487 test1488 test1489 \
\
test1500 test1501 test1502 test1503 test1504 test1505 test1506 test1507 \
test1508 test1509 test1510 test1511 test1512 test1513 test1514 test1515 \
--- /dev/null
+<testcase>
+<info>
+<keywords>
+HTTP
+HTTP GET
+</keywords>
+</info>
+
+#
+# Server-side
+<reply>
+<data crlf="yes" nocheck="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>
+<name>
+-D sent to stderr
+</name>
+<command option="no-include">
+http://%HOSTIP:%HTTPPORT/%TESTNUMBER -D % -s
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<protocol crlf="yes">
+GET /%TESTNUMBER HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+
+</protocol>
+<stderr 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
+
+</stderr>
+</verify>
+</testcase>