Created
December 19, 2017 14:11
-
-
Save robatwilliams/9c3eb6c0d641571f489d3f4249df5061 to your computer and use it in GitHub Desktop.
Check expected & unexpected HTTP headers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HTTP/1.1 200 OK | |
Content-Encoding: gzip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
headers="$(curl -sS -IX GET -H "Accept-Encoding: gzip" www.bbc.com)" | |
# should not find any unmatched patterns | |
missingExpected="$(grep -oxFf expected.txt <<< $headers | grep -vxFf - expected.txt)" | |
expected=$? | |
# should not find any matched patterns | |
presentUnexpected="$(grep -oxFf unexpected.txt <<< $headers)" | |
unexpected=$? | |
[ "$expected" -eq 0 ] && echo -e "*** Missing expected: ***\n$missingExpected" | |
[ "$unexpected" -eq 0 ] && echo -e "*** Present unexpected: ***\n$presentUnexpected" | |
exit $((2 - $expected - $unexpected)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Server: nginx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment