curl: two new command line options for etags

--etag-compare and --etag-save

Suggested-by: Paul Hoffman
Fixes #4277
Closes #4543
This commit is contained in:
Maros Priputen 2019-10-30 09:43:14 +01:00 committed by Daniel Stenberg
parent 1ff63fa69b
commit 18e5cb77e9
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
15 changed files with 390 additions and 3 deletions

View file

@ -38,6 +38,8 @@ DPAGES = \
dump-header.d \
egd-file.d \
engine.d \
etag-save.d \
etag-compare.d \
expect100-timeout.d \
fail-early.d \
fail.d \

View file

@ -0,0 +1,17 @@
Long: etag-compare
Arg: <file>
Help: Pass an ETag from a file as a custom header
Protocols: HTTP
---
This option makes a conditional HTTP request for the specific
ETag read from the given file by sending a custom If-None-Match
header using the extracted ETag.
For correct results, make sure that specified file contains only a single
line with a desired ETag. An empty file is parsed as an empty ETag.
Use the option --etag-save to first save the ETag from a response, and
then use this option to compare using the saved ETag in a subsequent request.
\fCOMPARISON\fP: There are 2 types of comparison or ETags, Weak and Strong.
This option expects, and uses a strong comparison.

View file

@ -0,0 +1,15 @@
Long: etag-save
Arg: <file>
Help: Parse ETag from a request and save it to a file
Protocols: HTTP
---
This option saves an HTTP ETag to the specified file. Etag is
usually part of headers returned by a request. When server sends an
ETag, it must be enveloped by a double quote. This option extracts the
ETag without the double quotes and saves it into the <file>.
A server can send a week ETag which is prefixed by "W/". This identifier
is not considered, and only relevant ETag between quotation marks is parsed.
It an ETag wasn't send by the server or it cannot be parsed, and empty
file is created.