Advertisement
xGHOSTSECx

ghana

Jan 6th, 2024
1,082
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.13 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. url="https://api.ghana.gov.gh"
  4. response_headers="response_headers.txt"
  5. response_body="response_body.txt"
  6.  
  7. for ((i=1; i<=3; i++)); do
  8.     curl -v -L -i -o /dev/null --connect-timeout 10 --trace-ascii trace_log.txt \
  9.         --resolve "api.ghana.gov.gh:443:$(dig +short api.ghana.gov.gh)" \
  10.         --output error_log.txt --dns-timeout 5 --connect-timeout 10 \
  11.         --cert-status --user-agent "MyCustomUserAgent" \
  12.         --header "Authorization: Bearer YourAccessToken" \
  13.         --cacert /path/to/certificate.pem --cookie-jar cookies.txt \
  14.         --compressed --request POST --referer "https://example.com" \
  15.         --max-redirs 5 --remote-header-name --remote-name-all --location-trusted \
  16.         $url 2>&1 | tee >(grep -E "^[<|>]" > $response_headers) > $response_body
  17.  
  18.     http_code=$(curl -o /dev/null -s -w "%{http_code}" $url)
  19.    
  20.     if [ $http_code -eq 200 ]; then
  21.         echo "Request successful (HTTP 200)"
  22.         break
  23.     elif [ $i -lt 3 ]; then
  24.         echo "Retrying... (Attempt $i)"
  25.         sleep 5
  26.     else
  27.         echo "Failed after $i attempts. Exiting."
  28.         exit 1
  29.     fi
  30. done
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement