We do not follow 308 but FTL also doesn't suggest it

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER 2023-12-02 22:42:36 +01:00
parent 96bf07863f
commit 32a741b5c7
No known key found for this signature in database
GPG key ID: 00135ACBD90B28DD

View file

@ -25,7 +25,7 @@ TestAPIAvailability() {
# Query the API URLs from FTL using CHAOS TXT local.api.ftl # Query the API URLs from FTL using CHAOS TXT local.api.ftl
# The result is a space-separated enumeration of full URLs # The result is a space-separated enumeration of full URLs
# e.g., "http://localhost:80/api" "https://localhost:443/api" # e.g., "http://localhost:80/api/" "https://localhost:443/api/"
chaos_api_list="$(dig +short chaos txt local.api.ftl @127.0.0.1)" chaos_api_list="$(dig +short chaos txt local.api.ftl @127.0.0.1)"
# If the query was not successful, the variable is empty # If the query was not successful, the variable is empty
@ -45,8 +45,8 @@ TestAPIAvailability() {
# Test if the API is available at this URL # Test if the API is available at this URL
availabilityResonse=$(curl -skS -o /dev/null -w "%{http_code}" "${API_URL}auth") availabilityResonse=$(curl -skS -o /dev/null -w "%{http_code}" "${API_URL}auth")
# Test if http status code was 200 (OK), 308 (redirect, we follow) 401 (authentication required) # Test if http status code was 200 (OK) or 401 (authentication required)
if [ ! "${availabilityResonse}" = 200 ] && [ ! "${availabilityResonse}" = 308 ] && [ ! "${availabilityResonse}" = 401 ]; then if [ ! "${availabilityResonse}" = 200 ] && [ ! "${availabilityResonse}" = 401 ]; then
# API is not available at this port/protocol combination # API is not available at this port/protocol combination
API_PORT="" API_PORT=""
else else
@ -131,7 +131,7 @@ GetFTLData() {
# data is everything from response without the last 3 characters # data is everything from response without the last 3 characters
data=$(printf %s "${response%???}") data=$(printf %s "${response%???}")
if [ "${status}" = 200 ] || [ "${status}" = 308 ]; then if [ "${status}" = 200 ]; then
# response OK # response OK
echo "${data}" echo "${data}"
elif [ "${status}" = 000 ]; then elif [ "${status}" = 000 ]; then
@ -193,6 +193,3 @@ secretRead() {
# restore original terminal settings # restore original terminal settings
stty "${stty_orig}" stty "${stty_orig}"
} }
TestAPIAvailability