fix body encoding
هذا الالتزام موجود في:
13
test_api.sh
13
test_api.sh
@@ -51,6 +51,13 @@ jq -c '.[]' "$TEST_FILE" | while read -r test; do
|
|||||||
retries=$(jq -r '.retries // 0' <<<"$test")
|
retries=$(jq -r '.retries // 0' <<<"$test")
|
||||||
follow_location=$(jq -r '.follow_location // false' <<<"$test")
|
follow_location=$(jq -r '.follow_location // false' <<<"$test")
|
||||||
|
|
||||||
|
encoded_body=""
|
||||||
|
if [[ -n "$body" ]]; then
|
||||||
|
if ! encoded_body=$(jq -r '@json' <<<"$body" 2>/dev/null); then
|
||||||
|
echo "[$idx/$TOTAL] $name -> ERROR: Invalid JSON body" >&2
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
CURL_HDR_ARGS=()
|
CURL_HDR_ARGS=()
|
||||||
if jq -e 'type=="object"' <<<"$headers_json" >/dev/null 2>&1; then
|
if jq -e 'type=="object"' <<<"$headers_json" >/dev/null 2>&1; then
|
||||||
@@ -143,8 +150,6 @@ jq -c '.[]' "$TEST_FILE" | while read -r test; do
|
|||||||
cat "$temp_resp" >&2
|
cat "$temp_resp" >&2
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (( attempt <= retries )); then sleep 1; continue; else break; fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
result=$(jq -n \
|
result=$(jq -n \
|
||||||
@@ -162,6 +167,10 @@ jq -c '.[]' "$TEST_FILE" | while read -r test; do
|
|||||||
echo "[$idx/$TOTAL] $name -> OK (status $http_code, ${latency_ms}ms)"
|
echo "[$idx/$TOTAL] $name -> OK (status $http_code, ${latency_ms}ms)"
|
||||||
else
|
else
|
||||||
echo "[$idx/$TOTAL] $name -> FAIL (status ${http_code:-n/a}, reason: $last_err)" >&2
|
echo "[$idx/$TOTAL] $name -> FAIL (status ${http_code:-n/a}, reason: $last_err)" >&2
|
||||||
|
if [[ -s "$temp_resp" ]]; then
|
||||||
|
echo "Response body:" >&2
|
||||||
|
cat "$temp_resp" >&2
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f "$temp_resp"
|
rm -f "$temp_resp"
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم