← Commit list

6fafe47082

Daniel Stenberg
Daniel Stenberg
2026-08-26
SUCCESS Duration: 397s

Subject

tool_cb_hdr: do not truncate etags output to stdout

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

src/tool_cb_hdr.c+1 -0
@@ -268,6 +268,7 @@ static size_t save_etag(const char *etag_h, const char *endp,
/* Truncate regular files to avoid stale etag content */
if((fd != -1) &&
+ etag_save->regular_file &&
!curlx_fstat(fd, &file) &&
(S_ISREG(file.st_mode) &&
toolx_ftruncate(fd, 0)))
tests/data/Makefile.am+1 -1
@@ -60,7 +60,7 @@ test280 test281 test282 test283 test284 test285 test286 test287 test288 \
test289 test290 test291 test292 test293 test294 test295 test296 test297 \
test298 test299 test300 test301 test302 test303 test304 test305 test306 \
test307 test308 test309 test310 test311 test312 test313 test314 test315 \
-test316 test317 test318 test319 test320 \
+test316 test317 test318 test319 test320 test321 \
test325 test326 test327 test328 test329 test330 test331 test332 test333 \
test334 test335 test336 test337 test338 test339 test340 test341 test342 \
test343 test344 test345 test346 test347 test348 test349 test350 test351 \
tests/data/test321+50 -0
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="US-ASCII"?>
+<testcase>
+<info>
+<keywords>
+etags
+</keywords>
+</info>
+
+# Server-side
+<reply>
+<data crlf="headers">
+HTTP/1.1 200 OK
+ETag: "remote"
+Content-Length: 0
+
+</data>
+</reply>
+
+# Client-side
+<client>
+<server>
+http
+</server>
+<name>
+--etag-save to stdout append to file
+</name>
+<command option="no-stdout">
+http://%HOSTIP:%HTTPPORT/%TESTNUMBER --etag-save - >> %LOGDIR/out%TESTNUMBER
+</command>
+
+<file name="%LOGDIR/out%TESTNUMBER">
+initial content
+</file>
+</client>
+
+# Verify data after the test has been "shot"
+<verify>
+<protocol crlf="headers">
+GET /%TESTNUMBER HTTP/1.1
+Host: %HOSTIP:%HTTPPORT
+User-Agent: curl/%VERSION
+Accept: */*
+
+</protocol>
+<file name="%LOGDIR/out%TESTNUMBER">
+initial content
+"remote"
+</file>
+</verify>
+</testcase>