forked from RipcordSoftware/libhttpserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·149 lines (129 loc) · 4.42 KB
/
Copy pathtest.sh
File metadata and controls
executable file
·149 lines (129 loc) · 4.42 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/usr/bin/env bash
if [ "$CONF" = "" ]; then
CONF=Debug
fi
URL=http://localhost:10024
SERVER_ROOT="${PWD}/dist/${CONF}/GNU-Linux-x86"
WEB_ROOT="${SERVER_ROOT}/www"
uris=(`find "${WEB_ROOT}" -type f | cut -c "${#WEB_ROOT}"- | cut -c 3-`)
pushd() { builtin pushd "$1" > /dev/null; }
popd() { builtin popd > /dev/null; }
"${SERVER_ROOT}/httpserver" &
sleep 2
trap 'kill %1' 0
rm -rf tmp.test
mkdir tmp.test
pushd tmp.test
# spider the web files with wget
echo "*******************************************************************"
echo "* spider test"
echo "*******************************************************************"
mkdir spider.test
pushd spider.test
wget -4 -r --no-host-directories ${URL}
if [ $? -ne 0 ]; then exit 1; fi
popd
echo "*******************************************************************"
echo "* HTTP/1.0 test"
echo "*******************************************************************"
mkdir http10.test
pushd http10.test
for uri in "${uris[@]}"
do
echo "* requesting: ${URL}/${uri}"
curl -4 -0 ${URL}/${uri} -o ${uri} --create-dirs
if [ $? -ne 0 ]; then exit 2; fi
diff --brief ${WEB_ROOT}/${uri} ${uri} > /dev/null
if [ $? -ne 0 ]; then exit 2; fi
done
popd
echo "*******************************************************************"
echo "* HTTP/1.0 redirect test"
echo "*******************************************************************"
mkdir http10.redirect.test
pushd http10.redirect.test
curl -4 -0 -L ${URL}/ -o index.html
if [ $? -ne 0 ]; then exit 3; fi
if [ ! -f "index.html" ]; then exit 1; fi
diff --brief ${WEB_ROOT}/index.html index.html > /dev/null
if [ $? -ne 0 ]; then exit 3; fi
popd
echo "*******************************************************************"
echo "* HTTP/1.1 redirect test"
echo "*******************************************************************"
mkdir http11.redirect.test
pushd http11.redirect.test
curl -4 -L ${URL} -o index.html
if [ $? -ne 0 ]; then exit 4; fi
if [ ! -f "index.html" ]; then exit 1; fi
diff --brief ${WEB_ROOT}/index.html index.html > /dev/null
if [ $? -ne 0 ]; then exit 4; fi
popd
echo "*******************************************************************"
echo "* HTTP/1.1 close test"
echo "*******************************************************************"
mkdir http11.close.test
pushd http11.close.test
for uri in "${uris[@]}"
do
echo "* requesting: ${URL}/${uri}"
curl -4 --header "Connection: close" ${URL}/${uri} -o ${uri} --create-dirs
if [ $? -ne 0 ]; then exit 5; fi
diff --brief ${WEB_ROOT}/${uri} ${uri} > /dev/null
if [ $? -ne 0 ]; then exit 5; fi
done
popd
# request gzipped web files with curl
echo "*******************************************************************"
echo "* gzip test"
echo "*******************************************************************"
mkdir gzip.test
pushd gzip.test
for uri in "${uris[@]}"
do
if [[ ! ${uri} =~ \.jpg$|\.eot$|\.woff[0-9]?$ ]]; then
echo "* requesting: ${URL}/${uri}"
curl -4 --header "Accept-Encoding: gzip" ${URL}/${uri} -o ${uri}.gz --create-dirs
if [ $? -ne 0 ]; then exit 6; fi
# if the file is gzipped then test it
file ${uri}.gz | grep gzip
if [ $? -eq 0 ]; then
gunzip -t $uri.gz || exit 6
else
exit 6
fi
fi
done
popd
# echo to/from the web server (fixed length)
echo "*******************************************************************"
echo "* fixed echo test"
echo "*******************************************************************"
mkdir echo.fixed.test
pushd echo.fixed.test
for uri in "${uris[@]}"
do
echo "* requesting: ${WEB_ROOT}/${uri}"
curl -4 -X POST ${URL}/echo --data-binary @${WEB_ROOT}/${uri} -o ${uri} --create-dirs
if [ $? -ne 0 ]; then exit 7; fi
diff --brief ${WEB_ROOT}/${uri} ${uri} > /dev/null
if [ $? -ne 0 ]; then exit 7; fi
done
popd
# echo to/from the web server (chunked)
echo "*******************************************************************"
echo "* chunked echo test"
echo "*******************************************************************"
mkdir echo.chunked.test
pushd echo.chunked.test
for uri in "${uris[@]}"
do
echo "* requesting: ${WEB_ROOT}/${uri}"
curl -4 -X POST ${URL}/echo --header "Transfer-Encoding: chunked" --data-binary @${WEB_ROOT}/${uri} -o ${uri} --create-dirs
if [ $? -ne 0 ]; then exit 8; fi
diff --brief ${WEB_ROOT}/${uri} ${uri} > /dev/null
if [ $? -ne 0 ]; then exit 8; fi
done
popd
popd
rm -rf tmp.test