mirror of
https://codeberg.org/vlw/curl.git
synced 2026-04-13 02:39:38 +02:00
Compare commits
No commits in common. "832bea42526d6c4510036fe1ae227170df12b20d" and "a42be0792cfb3f2be7b68fde904c2c4eb2f71387" have entirely different histories.
832bea4252
...
a42be0792c
2 changed files with 5 additions and 8 deletions
|
|
@ -1,4 +1,4 @@
|
|||

|
||||

|
||||
|
||||

|
||||
|
||||
|
|
|
|||
11
curl.sh
11
curl.sh
|
|
@ -1,8 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Check if the correct number of arguments is provided
|
||||
if [ -z "${1:-}" ]; then
|
||||
echo "Usage: $0 <url> [request_method]"
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Usage: $0 <url> <request_method>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ RESP_BODY_RAW_FILE="curl/resp_body.txt"
|
|||
RESP_BODY_JSON_FILE="curl/resp_body.json"
|
||||
|
||||
url="$1"
|
||||
method="${2:-GET}"
|
||||
method="$2"
|
||||
|
||||
# Append url search parameters
|
||||
if [ -f $REQ_PARAMS_FILE ]; then
|
||||
|
|
@ -66,11 +66,8 @@ curl_cmd="$curl_cmd -o $RESP_BODY_RAW_FILE -D $RESP_HEADERS_FILE"
|
|||
# Execute curl
|
||||
eval "clear"
|
||||
|
||||
echo -e "\e[0;92mRequest >\e[0m ${method} ${url}"
|
||||
echo -e "${method} ${url}"
|
||||
eval $curl_cmd
|
||||
|
||||
# Copy the raw respone body to a pretty-printed JSON file
|
||||
jq . $RESP_BODY_RAW_FILE > $RESP_BODY_JSON_FILE
|
||||
|
||||
# Print the response code
|
||||
echo -e -n "\e[0;94mResponse <\e[0m "; head -n 1 $RESP_HEADERS_FILE
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue