]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool_cb_hdr: suppress header output when --out-null
authorJay Satiro <raysatiro@yahoo.com>
Sun, 11 Jan 2026 19:56:24 +0000 (14:56 -0500)
committerJay Satiro <raysatiro@yahoo.com>
Mon, 12 Jan 2026 20:36:44 +0000 (15:36 -0500)
This change brings --out-null more in line with the documentation which
says --out-null is expected to behave like a portable -o /dev/null.

Prior to this change curl did not suppress the header output from --head
when --out-null was used to suppress output.

Assisted-by: Daniel Stenberg
Reported-by: Andrew Kvalheim
Ref: https://curl.se/docs/manpage.html#--out-null

Fixes https://github.com/curl/curl/discussions/20235
Closes https://github.com/curl/curl/pull/20256

src/tool_cb_hdr.c
tests/data/test756

index 573a1b7e2d2c84c88a59a7f737abc5c6e943f594..3b84f65d1fd10073920a651d434ee65de6e1d32d 100644 (file)
@@ -275,9 +275,9 @@ size_t tool_header_cb(char *ptr, size_t size, size_t nmemb, void *userdata)
     else if(ptr[0] == '\r' || ptr[0] == '\n')
       per->was_last_header_empty = TRUE;
   }
-  if(hdrcbdata->config->show_headers &&
-    (scheme == proto_http || scheme == proto_https ||
-     scheme == proto_rtsp || scheme == proto_file)) {
+  if(hdrcbdata->config->show_headers && !outs->out_null &&
+     (scheme == proto_http || scheme == proto_https ||
+      scheme == proto_rtsp || scheme == proto_file)) {
     /* bold headers only for selected protocols */
     char *value = NULL;
 
index 4b09c750dcfb771c1fd917f04383b556d69df718..013273dd78e8255ba92935e3033155e8ece29504 100644 (file)
@@ -61,13 +61,6 @@ Accept: */*
 
 </protocol>
 <stdout>
-HTTP/1.1 200 OK
-Date: Thu, 09 Nov 2010 14:49:00 GMT
-Server: test-server/fake
-Response: 1
-Content-Type: text/html
-Content-Length: 8
-
 HTTP/1.1 200 OK
 Date: Thu, 09 Nov 2010 14:49:00 GMT
 Server: test-server/fake