blob: 8e9463e78537b998489ba54d6dcfca723a9bf70c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#!/bin/sh
# Get values for HTTP headers for the given URL
# Check arguments
if [ "$#" -ne 2 ] ; then
printf 'urlt: Need an URL and a header name\n'
exit 2
fi
url=$1 header=$2
# Run cURL header request
curl -fIsSL -- "$url" |
# Unfold the headers
unf |
# Change the line endings to UNIX format
sd2u |
# Use awk to find any values for the header case-insensitively
awk -v header="$header" '
BEGIN {
FS=": *"
header = tolower(header)
}
tolower($1) == header {
sub(/^[^ ]*: */, "")
print
}
'
|