-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdiff-path.sh
87 lines (86 loc) · 1.77 KB
/
diff-path.sh
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
## diff-http-https-path.sh
## - diff protocol path request response
## version 0.2.1 - wip curl ua-device iphone
##################################################
set -e # exit on error
##################################################
if-domain-path() {
test "${domain}" && {
echo ${domain}${path}
true
} || {
echo ${path}
}
}
#-------------------------------------------------
curl-url-payload() {
local url
url=${protocol}://$( if-domain-path )
curl -ks ${url} -A "iPhone"
}
#-------------------------------------------------
curl-url-validate-protocol() {
case ${protocol} in
http|https) true ;;
*) false ;;
esac
}
#-------------------------------------------------
curl-url() { { local protocol ; protocol="${1}" ; }
curl-url-validate-protocol
curl-url-payload
}
#-------------------------------------------------
temp=
generate-temp() {
temp=$( basename ${0} .sh )-$( date +%s )-${RANDOM}
}
#-------------------------------------------------
_cleanup() {
test ! "${temp}" || {
rm ${temp}* --verbose 1>/dev/null
}
}
#-------------------------------------------------
diff-path-single() {
echo testing
generate-temp # ${temp}
for protocol in http https
do
echo ${protocol}
curl-url ${protocol} > ${temp}-${protocol} &
done
wait
diff ${temp}-* || true
_cleanup
}
#-------------------------------------------------
diff-path() {
test ! "${path}" || {
diff-path-single
return
}
while [ ! ]
do
read path
diff-path-single
done
}
##################################################
if [ ${#} -eq 2 ]
then
domain="${1}"
path="${2}"
elif [ ${#} -eq 1 ]
then
path="${1}"
elif [ ${#} -eq 0 ]
then
path=""
else
exit 1 # wrong args
fi
##################################################
diff-path
##################################################