Skip to content

tool_operate: don't truncate the etag save file by default - #13432

Closed
Gusted wants to merge 1 commit into
curl:masterfrom
Gusted:etag-save-compare
Closed

tool_operate: don't truncate the etag save file by default#13432
Gusted wants to merge 1 commit into
curl:masterfrom
Gusted:etag-save-compare

Conversation

@Gusted

@Gusted Gusted commented Apr 20, 2024

Copy link
Copy Markdown
Contributor

This fixes a regression of 75d79a4. The code in tool-operate truncated the etag save file, under the assumption that the file would be written with a new etag value. However since 75d79a4 that might not be the case anymore and could result in the file being truncated when --etag-compare and --etag-save was used and that the etag value matched with what the server responded. Instead the truncation should not be done when a new etag value should be written.

Test 3204 was added to verify that the file with the etag value doesn't change the contents when used by --etag-compare and --etage-save and that value matches with what the server returns on a non 2xx response.

A simple reproducer of this bug is using the command as advertised in the blog post:

curl --etag-compare etag.txt --etag-save etag.txt https://example.com -o saved-file

Run it three times and notice that for the second time it indeed doesn't download anything but for the third time it does, because on the second time the etag.txt is being truncated and nothing is being written back.

This fixes a regression of 75d79a4. The
code in tool-operate truncated the etag save file, under the assumption
that the file would be written with a new etag value. However since
75d79a4 that might not be the case
anymore and could result in the file being truncated when --etag-compare
and --etag-save was used and that the etag value matched with what the
server responded. Instead the truncation should not be done when a new
etag value should be written.

Test 3204 was added to verify that the file with the etag value doesn't
change the contents when used by --etag-compare and --etage-save and
that value matches with what the server returns on a non 2xx response.
Comment thread src/tool_operate.c
@bagder bagder self-assigned this Apr 22, 2024
@bagder

bagder commented Apr 23, 2024

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants