From 26311ac87c5c1f8c7f41170579a3136ac8b804df Mon Sep 17 00:00:00 2001 From: Tom Scavo Date: Wed, 26 Apr 2017 12:44:58 -0400 Subject: [PATCH 1/2] Update example in overview section --- README.md | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f9713fe..66db706 100644 --- a/README.md +++ b/README.md @@ -62,41 +62,58 @@ $ echo $? $ ls -1 $CACHE_DIR 1e6b844a49d1850b82feded72cf83ed7_content 1e6b844a49d1850b82feded72cf83ed7_headers +cget_log.txt $ cat $CACHE_DIR/1e6b844a49d1850b82feded72cf83ed7_headers HTTP/1.1 200 OK -Date: Sat, 29 Oct 2016 18:48:29 GMT +Date: Wed, 26 Apr 2017 16:29:44 GMT Server: Apache -Last-Modified: Fri, 28 Oct 2016 19:11:49 GMT -ETag: "1f802b-252f7f2-53ff1a146e740" +Last-Modified: Tue, 25 Apr 2017 19:14:05 GMT +ETag: "299866f-54e0286fb789a" Accept-Ranges: bytes -Content-Length: 38991858 -Connection: close +Content-Length: 43615855 Content-Type: application/samlmetadata+xml + +$ cat $CACHE_DIR/cget_log.txt +2017-04-26T16:29:44Z cget.sh requesting resource: http://md.incommon.org/InCommon/InCommon-metadata-preview.xml +2017-04-26T16:30:09Z conditional_get received response code: 200 +2017-04-26T16:30:10Z conditional_get writing cached content file: /tmp/http_cache/1e6b844a49d1850b82feded72cf83ed7_content +2017-04-26T16:30:10Z conditional_get reading cached content file: /tmp/http_cache/1e6b844a49d1850b82feded72cf83ed7_content ``` Assuming the resource doesn't change on the server, subsequent requests will return the cached resource. To bypass the network altogether, use the ``-C`` option: ```Shell $ $BIN_DIR/cget.sh -C $url1 | wc -c - 38991858 + 43615855 ``` Of course the ``-C`` option will fail if the resource is not cached: ```Shell -$ $BIN_DIR/cget.sh -C $url2 2> /dev/tty -ERROR: conditional_get: resource not cached: http://md.incommon.org/InCommon/InCommon-metadata-fallback.xml +# illustrate "quiet failure mode" +$ $BIN_DIR/cget.sh -C $url2 $ echo $? 1 +$ cat $CACHE_DIR/cget_log.txt | tail -n 2 +2017-04-26T16:39:38Z cget.sh requesting resource: http://md.incommon.org/InCommon/InCommon-metadata-fallback.xml +2017-04-26T16:39:38Z conditional_get: ERROR: resource not cached: http://md.incommon.org/InCommon/InCommon-metadata-fallback.xml ``` OTOH, the ``-F`` option forces the return of a fresh resource from the server. If the resource is cached and unchanged on the server (304), such a request will fail, however: ```Shell -$ $BIN_DIR/cget.sh -F $url1 2> /dev/tty -ERROR: conditional_get: resource not modified: http://md.incommon.org/InCommon/InCommon-metadata-preview.xml +# again illustrate "quiet failure mode" +$ $BIN_DIR/cget.sh -F $url1 $ echo $? 1 +$ cat $CACHE_DIR/cget_log.txt | tail -n 2 +2017-04-26T16:41:55Z conditional_get received response code: 304 +2017-04-26T16:41:55Z conditional_get: ERROR: resource not modified: http://md.incommon.org/InCommon/InCommon-metadata-preview.xml +``` + +The ``-F`` option will work on the other URL, however: + +```Shell $ $BIN_DIR/cget.sh -F $url2 > /dev/null $ echo $? 0 From 7aecf7a11021ff059778bb7db045ca0cf84dcb05 Mon Sep 17 00:00:00 2001 From: Tom Scavo Date: Wed, 26 Apr 2017 13:07:46 -0400 Subject: [PATCH 2/2] Update example in overview section --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 66db706..4deb2a1 100644 --- a/README.md +++ b/README.md @@ -74,10 +74,10 @@ Content-Length: 43615855 Content-Type: application/samlmetadata+xml $ cat $CACHE_DIR/cget_log.txt -2017-04-26T16:29:44Z cget.sh requesting resource: http://md.incommon.org/InCommon/InCommon-metadata-preview.xml -2017-04-26T16:30:09Z conditional_get received response code: 200 -2017-04-26T16:30:10Z conditional_get writing cached content file: /tmp/http_cache/1e6b844a49d1850b82feded72cf83ed7_content -2017-04-26T16:30:10Z conditional_get reading cached content file: /tmp/http_cache/1e6b844a49d1850b82feded72cf83ed7_content +2017-04-26T16:29:44Z INFO cget.sh requesting resource: http://md.incommon.org/InCommon/InCommon-metadata-preview.xml +2017-04-26T16:30:09Z INFO conditional_get received response code: 200 +2017-04-26T16:30:10Z INFO conditional_get writing cached content file: /tmp/http_cache/1e6b844a49d1850b82feded72cf83ed7_content +2017-04-26T16:30:10Z INFO conditional_get reading cached content file: /tmp/http_cache/1e6b844a49d1850b82feded72cf83ed7_content ``` Assuming the resource doesn't change on the server, subsequent requests will return the cached resource. To bypass the network altogether, use the ``-C`` option: @@ -95,8 +95,8 @@ $ $BIN_DIR/cget.sh -C $url2 $ echo $? 1 $ cat $CACHE_DIR/cget_log.txt | tail -n 2 -2017-04-26T16:39:38Z cget.sh requesting resource: http://md.incommon.org/InCommon/InCommon-metadata-fallback.xml -2017-04-26T16:39:38Z conditional_get: ERROR: resource not cached: http://md.incommon.org/InCommon/InCommon-metadata-fallback.xml +2017-04-26T16:39:38Z INFO cget.sh requesting resource: http://md.incommon.org/InCommon/InCommon-metadata-fallback.xml +2017-04-26T16:39:38Z ERROR conditional_get: resource not cached: http://md.incommon.org/InCommon/InCommon-metadata-fallback.xml ``` OTOH, the ``-F`` option forces the return of a fresh resource from the server. If the resource is cached and unchanged on the server (304), such a request will fail, however: @@ -107,8 +107,8 @@ $ $BIN_DIR/cget.sh -F $url1 $ echo $? 1 $ cat $CACHE_DIR/cget_log.txt | tail -n 2 -2017-04-26T16:41:55Z conditional_get received response code: 304 -2017-04-26T16:41:55Z conditional_get: ERROR: resource not modified: http://md.incommon.org/InCommon/InCommon-metadata-preview.xml +2017-04-26T16:41:55Z INFO conditional_get received response code: 304 +2017-04-26T16:41:55Z ERROR conditional_get: resource not modified: http://md.incommon.org/InCommon/InCommon-metadata-preview.xml ``` The ``-F`` option will work on the other URL, however: