From 49e0774477d2c75b1e628a3150fa7cb3ae1d5696 Mon Sep 17 00:00:00 2001 From: youssefammi123 <149005042+youssefammi123@users.noreply.github.com> Date: Tue, 9 Jul 2024 00:26:38 +0100 Subject: [PATCH] 3-methods.sh changer --- 0x10-python-network_0/3-methods.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/0x10-python-network_0/3-methods.sh b/0x10-python-network_0/3-methods.sh index 531b07e..26ecd38 100755 --- a/0x10-python-network_0/3-methods.sh +++ b/0x10-python-network_0/3-methods.sh @@ -1,3 +1,10 @@ #!/bin/bash -# Display all HTTP methods the server of a given URL will accept. -curl -sI "$1" | grep "Allow" | cut -d " " -f 2- + +# Check if a URL was provided as an argument +if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 +fi + +# Send an OPTIONS request using curl and extract the Allow header +curl -sI -X OPTIONS "$1" | grep "Allow:" | cut -d ' ' -f2-