diff options
author | Jefferson Julio <[email protected]> | 2022-05-15 20:37:44 -0300 |
---|---|---|
committer | Jefferson Julio <[email protected]> | 2022-05-15 20:57:38 -0300 |
commit | d4305ad115c9e1ac4f62bfaa05929f2de8a5999d (patch) | |
tree | 10f3f970573127127b8a4360c0665b616e1f84da | |
parent | abf68c8495edd9b99789ac6dd97e536fa0fe9234 (diff) | |
download | rest-run-d4305ad115c9e1ac4f62bfaa05929f2de8a5999d.tar.bz2 rest-run-d4305ad115c9e1ac4f62bfaa05929f2de8a5999d.zip |
Change timestamp format. Write request url to history file.
-rwxr-xr-x | rest-run | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -226,19 +226,20 @@ CACHE_DIR_CONTEXT_REQUEST="${CACHE_DIR_CONTEXT}/request" mkdir -p "$CACHE_DIR_CONTEXT_RESPONSE" > /dev/null mkdir -p "$CACHE_DIR_CONTEXT_REQUEST" > /dev/null -rest_timestamp="$(date +"%s")" -rest_request_file="$CACHE_DIR_CONTEXT_REQUEST/request-$rest_timestamp.json" +rest_method="${rest_method^^}" +rest_timestamp="$(date +"%y-%m-%d_%H:%M")" +rest_request_file="$CACHE_DIR_CONTEXT_REQUEST/$rest_method-request-$rest_timestamp.log" last_request_file="$(find "$CACHE_DIR_CONTEXT_REQUEST" -type f | sort -n | tail -1)" if [ ${#rest_response_file} -lt 1 ]; then - rest_response_file="$CACHE_DIR_CONTEXT_RESPONSE/response-$rest_timestamp.log" + rest_response_file="$CACHE_DIR_CONTEXT_RESPONSE/$rest_method-response-$rest_timestamp.log" fi if ! [[ -z "$last_request_file" || "${#last_request_file}" = "0" ]]; then last_request_file_checksum="$(cat "$last_request_file" | sha1sum | awk '{print $1}')" fi -if [[ "$rest_method" = "GET" || "$rest_method" = "get" ]]; then +if [[ "$rest_method" = "GET" ]]; then ignore_body=true fi @@ -256,6 +257,10 @@ fi # [ rest-run! +write-history () { + echo "$rest_method $rest_url" >> "$CACHE_DIR/request-history" +} + output-response () { case "$rest_output_extract" in @@ -345,6 +350,7 @@ if [ $ignore_body = false ]; then # Send request body | eval -- http -p "$httpie_print_options" --pretty=all \ "$rest_method" \"$rest_url\" $(for h in "${rest_headers[@]}"; do echo \"$h\"; done) -o "$rest_response_file" + write-history output-response current_request_checksum="$(cat "$rest_request_file" | sha1sum | awk '{print $1}')" @@ -358,6 +364,7 @@ else # Send request without body eval -- http --pretty=all -p "$httpie_print_options" \ "$rest_method" \"$rest_url\" $(for h in "${rest_headers[@]}"; do echo \"$h\"; done) -o "$rest_response_file" + write-history output-response fi |