38 lines
903 B
Bash
Executable File
38 lines
903 B
Bash
Executable File
#!/bin/bash
|
|
|
|
function TestGetHeader()
|
|
{
|
|
curlHeaderOutputFile="./temp"
|
|
if curl -I $1 --output $curlHeaderOutputFile 2> /dev/null; then
|
|
regexPattern="Content\-Type: $2"
|
|
headerContentType="$(egrep -o "$regexPattern" $curlHeaderOutputFile)"
|
|
if [ -n "$headerContentType" ]; then
|
|
echo "SUCCESS HEAD $1"
|
|
else
|
|
echo "FAILURE HEAD $1 contains bad MIME type (expected <Content-Type: $2> but got <$headerContentType>)"
|
|
fi
|
|
|
|
rm $curlHeaderOutputFile
|
|
else
|
|
echo "FAILURE Cannot HEAD $1"
|
|
fi
|
|
}
|
|
|
|
function TestHEAD()
|
|
{
|
|
getUrl="http://localhost:8080/$1"
|
|
|
|
TestGetHeader $getUrl $2
|
|
echo ""
|
|
}
|
|
|
|
echo "*********"
|
|
echo "HEAD TEST"
|
|
echo "*********"
|
|
TestHEAD "index.html" 'text/html'
|
|
TestHEAD "robedude.png" 'image/png'
|
|
TestHEAD "hope.jpg" 'image/jpeg'
|
|
TestHEAD "nevada.mp3" 'audio/mpeg3'
|
|
TestHEAD "index.css" 'text/css'
|
|
TestHEAD "test.js" 'application/javascript'
|
|
TestHEAD "subdir/index.html" 'text/html' |