1
0
mirror of https://github.com/pi-hole/pi-hole synced 2025-01-02 20:20:56 +00:00

Only separat data and status when needed

Signed-off-by: Christian König <github@yubiuser.dev>
This commit is contained in:
Christian König 2024-12-22 21:55:25 +01:00
parent d80259ee8f
commit c777152c04
No known key found for this signature in database

View File

@ -165,15 +165,16 @@ GetFTLData() {
# get the data from querying the API as well as the http status code
response=$(curl -skS -w "%{http_code}" -X GET "${API_URL}$1" -H "Accept: application/json" -H "sid: ${SID}" )
# status are the last 3 characters
status="${response#"${response%???}"}"
# data is everything from response without the last 3 characters
data="${response%???}"
if [ "${2}" = "raw" ]; then
# return the raw response
echo "${response}"
else
# status are the last 3 characters # status are the last 3 characters
status="${response#"${response%???}"}"
# data is everything from response without the last 3 characters
data="${response%???}"
# return only the data
if [ "${status}" = 200 ]; then
# response OK