From edd5b53b33e15e78194e5b16230e7f7be1b5d0fc Mon Sep 17 00:00:00 2001 From: Tom Scavo <trscavo@internet2.edu> Date: Wed, 14 Jun 2017 09:02:37 -0400 Subject: [PATCH] Initialize global variables --- bin/request_http_resources.sh | 26 +++++++++++++++++++------- bin/test_compressed_resources.sh | 27 ++++++++++++++++++++------- 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/bin/request_http_resources.sh b/bin/request_http_resources.sh index 0f7c52c..619a90d 100755 --- a/bin/request_http_resources.sh +++ b/bin/request_http_resources.sh @@ -274,7 +274,7 @@ append_json_object () { local response_code=$( escape_special_json_chars "$response_code" ) local response_date=$( escape_special_json_chars "$response_date" ) local last_modified=$( escape_special_json_chars "$last_modified" ) - local e_tag=$( escape_special_json_chars "$e_tag" ) + local etag=$( escape_special_json_chars "$etag" ) local content_length=$( escape_special_json_chars "$content_length" ) local content_type=$( escape_special_json_chars "$content_type" ) @@ -289,13 +289,28 @@ append_json_object () { "ResponseCode": "$response_code", "Date": "$response_date", "LastModified": "$last_modified", - "ETag": "$e_tag", + "ETag": "$etag", "ContentLength": "$content_length", "ContentType": "$content_type" } JSON_OBJECT } +init_global_vars () { + + # success by default + success=true + message="Resource request successful" + + location= + ResponseCode= + Date= + LastModified= + ETag= + ContentLength= + ContentType= +} + get_response () { local status_code @@ -313,8 +328,6 @@ get_response () { return 3 fi - # success - message="Resource request successful" return 0 } @@ -348,7 +361,7 @@ parse_response () { # get the ETag response header header_name=ETag - e_tag=$( get_header_value $header_file $header_name ) + etag=$( get_header_value $header_file $header_name ) status_code=$? if [ $status_code -ne 0 ]; then print_log_message -E "$script_name: get_header_value failed ($status_code) to parse response header: $header_name" @@ -380,8 +393,7 @@ print_output_file () { while true; do - success=true - + init_global_vars get_response "$1" status_code=$? if [ $status_code -eq 0 ]; then diff --git a/bin/test_compressed_resources.sh b/bin/test_compressed_resources.sh index 81c96da..aa753b6 100755 --- a/bin/test_compressed_resources.sh +++ b/bin/test_compressed_resources.sh @@ -283,7 +283,7 @@ append_json_object () { local response_code=$( escape_special_json_chars "$response_code" ) local response_date=$( escape_special_json_chars "$response_date" ) local last_modified=$( escape_special_json_chars "$last_modified" ) - local e_tag=$( escape_special_json_chars "$e_tag" ) + local etag=$( escape_special_json_chars "$etag" ) local content_length=$( escape_special_json_chars "$content_length" ) local content_type=$( escape_special_json_chars "$content_type" ) local content_encoding=$( escape_special_json_chars "$content_encoding" ) @@ -299,7 +299,7 @@ append_json_object () { "ResponseCode": "$response_code", "Date": "$response_date", "LastModified": "$last_modified", - "ETag": "$e_tag", + "ETag": "$etag", "ContentLength": "$content_length", "ContentType": "$content_type", "ContentEncoding": "$content_encoding" @@ -307,6 +307,22 @@ append_json_object () { JSON_OBJECT } +init_global_vars () { + + # success by default + success=true + message="Integrity of compressed metadata confirmed" + + location= + ResponseCode= + Date= + LastModified= + ETag= + ContentLength= + ContentType= + ContentEncoding= +} + get_compressed_response () { local status_code @@ -357,7 +373,7 @@ parse_compressed_response () { # get the ETag response header header_name=ETag - e_tag=$( get_header_value $header_file $header_name ) + etag=$( get_header_value $header_file $header_name ) status_code=$? if [ $status_code -ne 0 ]; then print_log_message -E "$script_name: get_header_value failed ($status_code) to parse response header: $header_name" @@ -438,8 +454,6 @@ test_compressed_response () { fi print_log_message -D "$script_name: compressed and uncompressed resources are identical" - # success - message="Integrity of compressed metadata confirmed" return 0 } @@ -452,8 +466,7 @@ print_output_file () { while true; do - success=true - + init_global_vars get_compressed_response "$1" status_code=$? if [ $status_code -eq 0 ]; then