Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create two new curl tool options to work with etags
removing unnecessary custom files, putting header processing to header callback function Adding new OutStruct for saving ETag to a file, and implementing function for saving adding compare functionality in tool_operate, and waiting for response header callback in tool_cb_hdr testing compare func fixing minor issues with writing, and constructin If-None-Match etag header with different functions adding tmp man pages, + fixing string formatting in etag-compare fix typos in man option definition, import library for strtok_r another fixes to satisfy builds create two new curl tool options to work with etag rewriting man pages, fixing issues mentioned in review fix sscanf width restriction lgtm complaint init local variable, alloc memory for it code pr quality fix fixes after review, adding 2 tests for --etag-save and --etag-compare type fix add new test, fix build errors and leaks type error
- Loading branch information
Maros Priputen
committed
Nov 13, 2019
1 parent
674298d
commit 6a0d7be
Showing
15 changed files
with
389 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<testcase> | ||
<info> | ||
<keywords> | ||
HTTP | ||
HTTP GET | ||
</keywords> | ||
</info> | ||
# | ||
# Server-side | ||
<reply> | ||
<data nocheck="yes"> | ||
HTTP/1.1 200 funky chunky! | ||
Server: fakeit/0.9 fakeitbad/1.0 | ||
Transfer-Encoding: chunked | ||
Trailer: chunky-trailer | ||
Connection: mooo | ||
ETag: "asdf" | ||
|
||
40 | ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | ||
30 | ||
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | ||
21;heresatest=moooo | ||
cccccccccccccccccccccccccccccccc | ||
|
||
0 | ||
chunky-trailer: header data | ||
|
||
</data> | ||
</reply> | ||
|
||
# | ||
# Client-side | ||
<client> | ||
<server> | ||
http | ||
</server> | ||
<name> | ||
Check if --etag-save saved correct etag to a file | ||
</name> | ||
<command> | ||
http://%HOSTIP:%HTTPPORT/339 --etag-save log/etag339 | ||
</command> | ||
</client> | ||
|
||
# | ||
# Verify data after the test has been "shot" | ||
<verify> | ||
<strip> | ||
^User-Agent:.* | ||
</strip> | ||
<protocol> | ||
GET /339 HTTP/1.1 | ||
Host: %HOSTIP:%HTTPPORT | ||
Accept: */* | ||
|
||
</protocol> | ||
<file name="log/etag339"> | ||
asdf | ||
</file> | ||
</verify> | ||
|
||
</testcase> |
Oops, something went wrong.