Blame


1 5741561d 2021-12-09 op test_punycode() {
2 a721c233 2021-12-09 op dont_check_server_alive=yes
3 5741561d 2021-12-09 op ./puny-test
4 5741561d 2021-12-09 op }
5 5741561d 2021-12-09 op
6 5741561d 2021-12-09 op test_iri() {
7 a721c233 2021-12-09 op dont_check_server_alive=yes
8 5741561d 2021-12-09 op ./iri_test
9 42235e3f 2024-04-04 op }
10 42235e3f 2024-04-04 op
11 42235e3f 2024-04-04 op test_dump_config() {
12 42235e3f 2024-04-04 op dont_check_server_alive=yes
13 42235e3f 2024-04-04 op gen_config '' ''
14 42235e3f 2024-04-04 op
15 42235e3f 2024-04-04 op exp="$(mktemp)"
16 42235e3f 2024-04-04 op got="$(mktemp)"
17 42235e3f 2024-04-04 op cat <<EOF >$exp
18 42235e3f 2024-04-04 op prefork 3
19 42235e3f 2024-04-04 op
20 42235e3f 2024-04-04 op server "localhost" {
21 42235e3f 2024-04-04 op cert "$PWD/localhost.pem"
22 42235e3f 2024-04-04 op key "$PWD/localhost.key"
23 42235e3f 2024-04-04 op }
24 42235e3f 2024-04-04 op EOF
25 42235e3f 2024-04-04 op
26 42235e3f 2024-04-04 op $gmid -nn -c reg.conf > $got 2>/dev/null
27 42235e3f 2024-04-04 op
28 42235e3f 2024-04-04 op ret=0
29 42235e3f 2024-04-04 op if ! cmp -s "$exp" "$got"; then
30 42235e3f 2024-04-04 op echo "config differs!" >&2
31 42235e3f 2024-04-04 op diff -u "$exp" "$got" >&2
32 42235e3f 2024-04-04 op ret=1
33 42235e3f 2024-04-04 op fi
34 42235e3f 2024-04-04 op
35 42235e3f 2024-04-04 op rm "$exp" "$got"
36 42235e3f 2024-04-04 op return $ret
37 5741561d 2021-12-09 op }
38 5741561d 2021-12-09 op
39 471a5250 2023-07-25 op test_gemexp() {
40 a721c233 2021-12-09 op dont_check_server_alive=yes
41 176179b2 2021-10-04 op
42 471a5250 2023-07-25 op $gemexp -p $port -d . testdata &
43 176179b2 2021-10-04 op pid=$!
44 176179b2 2021-10-04 op sleep 1
45 176179b2 2021-10-04 op
46 176179b2 2021-10-04 op fetch /
47 176179b2 2021-10-04 op kill $pid
48 176179b2 2021-10-04 op check_reply "20 text/gemini" "# hello world" || return 1
49 176179b2 2021-10-04 op }
50 176179b2 2021-10-04 op
51 176179b2 2021-10-04 op test_static_files() {
52 176179b2 2021-10-04 op setup_simple_test
53 176179b2 2021-10-04 op
54 176179b2 2021-10-04 op fetch /
55 176179b2 2021-10-04 op check_reply "20 text/gemini" "# hello world" || return 1
56 176179b2 2021-10-04 op
57 176179b2 2021-10-04 op fetch /foo
58 176179b2 2021-10-04 op check_reply "51 not found" || return 1
59 176179b2 2021-10-04 op
60 176179b2 2021-10-04 op fetch /dir/foo.gmi
61 176179b2 2021-10-04 op check_reply "20 text/gemini" "# hello world" || return 1
62 176179b2 2021-10-04 op }
63 176179b2 2021-10-04 op
64 176179b2 2021-10-04 op test_directory_redirect() {
65 176179b2 2021-10-04 op setup_simple_test
66 176179b2 2021-10-04 op
67 176179b2 2021-10-04 op fetch /dir
68 176179b2 2021-10-04 op check_reply "30 /dir/" || return 1
69 176179b2 2021-10-04 op
70 176179b2 2021-10-04 op fetch /dir/
71 176179b2 2021-10-04 op check_reply "51 not found" || return 1
72 176179b2 2021-10-04 op }
73 176179b2 2021-10-04 op
74 176179b2 2021-10-04 op test_serve_big_files() {
75 176179b2 2021-10-04 op setup_simple_test
76 176179b2 2021-10-04 op
77 176179b2 2021-10-04 op hdr="$(head /bigfile)"
78 176179b2 2021-10-04 op get /bigfile > bigfile
79 176179b2 2021-10-04 op
80 611dffe8 2023-06-13 op want="20 application/octet-stream"
81 611dffe8 2023-06-13 op if [ "$hdr" != "$want" ]; then
82 611dffe8 2023-06-13 op echo "Header mismatch" >&2
83 611dffe8 2023-06-13 op echo "wants : $want" >&2
84 611dffe8 2023-06-13 op echo "got : $hdr" >&2
85 611dffe8 2023-06-13 op return 1
86 611dffe8 2023-06-13 op fi
87 611dffe8 2023-06-13 op
88 611dffe8 2023-06-13 op if ! cmp -s bigfile testdata/bigfile; then
89 611dffe8 2023-06-13 op echo "received bigfile is not as expected"
90 611dffe8 2023-06-13 op cmp bigfile testdata/bigfile
91 611dffe8 2023-06-13 op return 1
92 611dffe8 2023-06-13 op fi
93 176179b2 2021-10-04 op }
94 176179b2 2021-10-04 op
95 176179b2 2021-10-04 op test_dont_execute_scripts() {
96 176179b2 2021-10-04 op setup_simple_test
97 176179b2 2021-10-04 op
98 176179b2 2021-10-04 op fetch_hdr /hello
99 176179b2 2021-10-04 op check_reply "20 application/octet-stream" "" || return 1
100 176179b2 2021-10-04 op }
101 176179b2 2021-10-04 op
102 176179b2 2021-10-04 op test_custom_mime() {
103 9448a01f 2022-04-07 op setup_simple_test '
104 9448a01f 2022-04-07 op types {
105 9448a01f 2022-04-07 op text/x-funny gmi
106 9448a01f 2022-04-07 op }
107 9448a01f 2022-04-07 op ' ''
108 176179b2 2021-10-04 op
109 176179b2 2021-10-04 op fetch_hdr /
110 176179b2 2021-10-04 op check_reply "20 text/x-funny"
111 176179b2 2021-10-04 op }
112 176179b2 2021-10-04 op
113 176179b2 2021-10-04 op test_default_type() {
114 176179b2 2021-10-04 op setup_simple_test '' 'default type "application/x-foo"'
115 176179b2 2021-10-04 op
116 176179b2 2021-10-04 op fetch_hdr /hello
117 176179b2 2021-10-04 op check_reply "20 application/x-foo"
118 176179b2 2021-10-04 op }
119 176179b2 2021-10-04 op
120 176179b2 2021-10-04 op test_custom_lang() {
121 176179b2 2021-10-04 op setup_simple_test '' 'lang it'
122 176179b2 2021-10-04 op
123 176179b2 2021-10-04 op fetch_hdr /
124 176179b2 2021-10-04 op check_reply "20 text/gemini;lang=it"
125 176179b2 2021-10-04 op }
126 176179b2 2021-10-04 op
127 176179b2 2021-10-04 op test_parse_custom_lang_per_location() {
128 176179b2 2021-10-04 op setup_simple_test '' \
129 176179b2 2021-10-04 op 'lang it location "/en/*" {lang en} location "/de/*" {lang de}'
130 176179b2 2021-10-04 op # can parse multiple locations
131 176179b2 2021-10-04 op }
132 176179b2 2021-10-04 op
133 176179b2 2021-10-04 op test_custom_index() {
134 176179b2 2021-10-04 op setup_simple_test '' 'index "foo.gmi"'
135 176179b2 2021-10-04 op
136 176179b2 2021-10-04 op fetch /dir/
137 176179b2 2021-10-04 op check_reply "20 text/gemini" "# hello world"
138 176179b2 2021-10-04 op }
139 176179b2 2021-10-04 op
140 176179b2 2021-10-04 op test_custom_index_default_type_per_location() {
141 176179b2 2021-10-04 op setup_simple_test '' 'location "/dir/*" { default type "text/plain" index "hello" }'
142 176179b2 2021-10-04 op
143 176179b2 2021-10-04 op fetch /dir/
144 176179b2 2021-10-04 op check_reply "20 text/plain" "$(cat hello)"
145 176179b2 2021-10-04 op }
146 176179b2 2021-10-04 op
147 176179b2 2021-10-04 op test_auto_index() {
148 176179b2 2021-10-04 op setup_simple_test '' 'location "/dir/*" { auto index on }'
149 176179b2 2021-10-04 op
150 176179b2 2021-10-04 op fetch /
151 176179b2 2021-10-04 op check_reply "20 text/gemini" "# hello world" || return 1
152 176179b2 2021-10-04 op
153 176179b2 2021-10-04 op fetch_hdr /dir
154 176179b2 2021-10-04 op check_reply "30 /dir/" || return 1
155 176179b2 2021-10-04 op
156 176179b2 2021-10-04 op fetch_hdr /dir/
157 475205fa 2022-07-04 op check_reply "20 text/gemini" || return 1
158 176179b2 2021-10-04 op
159 475205fa 2022-07-04 op get /dir/ > listing || return 1
160 475205fa 2022-07-04 op cat <<EOF > listing.expected
161 475205fa 2022-07-04 op # Index of /dir/
162 176179b2 2021-10-04 op
163 d45d5306 2022-07-04 op => ./../
164 475205fa 2022-07-04 op => ./current%20date
165 475205fa 2022-07-04 op => ./foo.gmi
166 475205fa 2022-07-04 op => ./hello
167 475205fa 2022-07-04 op EOF
168 176179b2 2021-10-04 op
169 475205fa 2022-07-04 op cmp -s listing.expected listing
170 475205fa 2022-07-04 op ret=$?
171 475205fa 2022-07-04 op if [ $ret -ne 0 ]; then
172 475205fa 2022-07-04 op echo 'unexpected dir content:'
173 475205fa 2022-07-04 op diff -u listing.expected listing
174 176179b2 2021-10-04 op fi
175 475205fa 2022-07-04 op rm listing listing.expected
176 475205fa 2022-07-04 op
177 475205fa 2022-07-04 op return $ret
178 176179b2 2021-10-04 op }
179 176179b2 2021-10-04 op
180 176179b2 2021-10-04 op test_block() {
181 176179b2 2021-10-04 op setup_simple_test '' 'location "*" { block }'
182 176179b2 2021-10-04 op
183 176179b2 2021-10-04 op fetch /
184 176179b2 2021-10-04 op check_reply "40 temporary failure" || return 1
185 176179b2 2021-10-04 op
186 176179b2 2021-10-04 op fetch /nonexists
187 176179b2 2021-10-04 op check_reply "40 temporary failure" || return 1
188 176179b2 2021-10-04 op }
189 176179b2 2021-10-04 op
190 176179b2 2021-10-04 op test_block_return_fmt() {
191 176179b2 2021-10-04 op setup_simple_test '' '
192 176179b2 2021-10-04 op location "/dir" {
193 176179b2 2021-10-04 op strip 1
194 176179b2 2021-10-04 op block return 40 "%% %p %q %P %N test"
195 176179b2 2021-10-04 op }
196 176179b2 2021-10-04 op location "*" {
197 176179b2 2021-10-04 op strip 99
198 176179b2 2021-10-04 op block return 40 "%% %p %q %P %N test"
199 176179b2 2021-10-04 op }'
200 176179b2 2021-10-04 op
201 176179b2 2021-10-04 op fetch_hdr /dir/foo.gmi
202 176179b2 2021-10-04 op check_reply "40 % /foo.gmi 10965 localhost test" || return 1
203 176179b2 2021-10-04 op
204 176179b2 2021-10-04 op fetch_hdr /bigfile
205 176179b2 2021-10-04 op check_reply "40 % / 10965 localhost test" || return 1
206 176179b2 2021-10-04 op }
207 176179b2 2021-10-04 op
208 176179b2 2021-10-04 op test_require_client_ca() {
209 176179b2 2021-10-04 op setup_simple_test '' 'require client ca "'$PWD'/testca.pem"'
210 176179b2 2021-10-04 op
211 176179b2 2021-10-04 op fetch /
212 176179b2 2021-10-04 op check_reply "60 client certificate required" || return 1
213 176179b2 2021-10-04 op
214 176179b2 2021-10-04 op ggflags="-C valid.crt -K valid.key"
215 176179b2 2021-10-04 op fetch_hdr /
216 176179b2 2021-10-04 op check_reply "20 text/gemini" || return 1
217 176179b2 2021-10-04 op
218 80745f04 2023-08-29 op ggflags="-C invalid.pem -K invalid.key"
219 176179b2 2021-10-04 op fetch_hdr /
220 176179b2 2021-10-04 op check_reply "61 certificate not authorised" || return 1
221 176179b2 2021-10-04 op }
222 176179b2 2021-10-04 op
223 176179b2 2021-10-04 op test_root_inside_location() {
224 176179b2 2021-10-04 op setup_simple_test '' 'location "/foo/*" { root "'$PWD'/testdata" strip 1 }'
225 176179b2 2021-10-04 op
226 176179b2 2021-10-04 op fetch /foo
227 176179b2 2021-10-04 op check_reply "51 not found" || return 1
228 176179b2 2021-10-04 op
229 176179b2 2021-10-04 op fetch_hdr /foo/
230 176179b2 2021-10-04 op check_reply "20 text/gemini"
231 176179b2 2021-10-04 op }
232 176179b2 2021-10-04 op
233 176179b2 2021-10-04 op test_root_inside_location_with_redirect() {
234 176179b2 2021-10-04 op setup_simple_test '' '
235 176179b2 2021-10-04 op location "/foo" { block return 31 "%p/" }
236 176179b2 2021-10-04 op location "/foo/*" { root "'$PWD'/testdata" strip 1 }'
237 176179b2 2021-10-04 op
238 176179b2 2021-10-04 op fetch /foo
239 176179b2 2021-10-04 op check_reply "31 /foo/" || return 1
240 176179b2 2021-10-04 op
241 176179b2 2021-10-04 op fetch_hdr /foo/
242 176179b2 2021-10-04 op check_reply "20 text/gemini"
243 176179b2 2021-10-04 op }
244 176179b2 2021-10-04 op
245 176179b2 2021-10-04 op test_fastcgi() {
246 9adeb265 2023-06-09 op ./fcgi-test fcgi.sock &
247 9adeb265 2023-06-09 op fcgi_pid=$!
248 176179b2 2021-10-04 op
249 fdd67729 2023-07-23 op setup_simple_test 'prefork 1' 'fastcgi socket "'$PWD'/fcgi.sock"'
250 2247b668 2023-07-01 op
251 2247b668 2023-07-01 op msg=$(printf "# hello from fastcgi!\nsome more content in the page...")
252 9adeb265 2023-06-09 op
253 9adeb265 2023-06-09 op i=0
254 9adeb265 2023-06-09 op while [ $i -lt 10 ]; do
255 9adeb265 2023-06-09 op fetch /
256 2247b668 2023-07-01 op check_reply "20 text/gemini" "$msg"
257 9adeb265 2023-06-09 op if [ $? -ne 0 ]; then
258 9adeb265 2023-06-09 op kill $fcgi_pid
259 9adeb265 2023-06-09 op return 1
260 9adeb265 2023-06-09 op fi
261 9adeb265 2023-06-09 op
262 9adeb265 2023-06-09 op i=$(($i + 1))
263 9adeb265 2023-06-09 op done
264 60f4107d 2023-07-23 op
265 60f4107d 2023-07-23 op kill $fcgi_pid
266 60f4107d 2023-07-23 op return 0
267 60f4107d 2023-07-23 op }
268 60f4107d 2023-07-23 op
269 60f4107d 2023-07-23 op test_fastcgi_inside_location() {
270 60f4107d 2023-07-23 op ./fcgi-test fcgi.sock &
271 60f4107d 2023-07-23 op fcgi_pid=$!
272 60f4107d 2023-07-23 op
273 60f4107d 2023-07-23 op setup_simple_test 'prefork 1' 'fastcgi socket "'$PWD'/fcgi.sock"
274 60f4107d 2023-07-23 op location "/dir/*" {
275 60f4107d 2023-07-23 op fastcgi off
276 60f4107d 2023-07-23 op }'
277 60f4107d 2023-07-23 op
278 60f4107d 2023-07-23 op msg=$(printf "# hello from fastcgi!\nsome more content in the page...")
279 60f4107d 2023-07-23 op fetch /foo
280 60f4107d 2023-07-23 op if ! check_reply "20 text/gemini" "$msg"; then
281 60f4107d 2023-07-23 op kill $fcgi_pid
282 60f4107d 2023-07-23 op return 1
283 60f4107d 2023-07-23 op fi
284 fdd67729 2023-07-23 op
285 60f4107d 2023-07-23 op fetch /dir/foo.gmi
286 60f4107d 2023-07-23 op if ! check_reply "20 text/gemini" "# hello world"; then
287 60f4107d 2023-07-23 op kill $fcgi_pid
288 60f4107d 2023-07-23 op return 1
289 60f4107d 2023-07-23 op fi
290 60f4107d 2023-07-23 op
291 fdd67729 2023-07-23 op kill $fcgi_pid
292 fdd67729 2023-07-23 op return 0
293 fdd67729 2023-07-23 op }
294 fdd67729 2023-07-23 op
295 fdd67729 2023-07-23 op test_fastcgi_deprecated_syntax() {
296 fdd67729 2023-07-23 op ./fcgi-test fcgi.sock &
297 fdd67729 2023-07-23 op fcgi_pid=$!
298 fdd67729 2023-07-23 op
299 fdd67729 2023-07-23 op # the old syntax will eventually go away, but check that the
300 fdd67729 2023-07-23 op # backward compatibility works.
301 fdd67729 2023-07-23 op setup_simple_test 'prefork 1' 'fastcgi "'$PWD'/fcgi.sock"'
302 9adeb265 2023-06-09 op
303 fdd67729 2023-07-23 op msg=$(printf "# hello from fastcgi!\nsome more content in the page...")
304 fdd67729 2023-07-23 op fetch /
305 fdd67729 2023-07-23 op check_reply "20 text/gemini" "$msg"
306 fdd67729 2023-07-23 op if [ $? -ne 0 ]; then
307 fdd67729 2023-07-23 op kill $fcgi_pid
308 fdd67729 2023-07-23 op return 1
309 fdd67729 2023-07-23 op fi
310 fdd67729 2023-07-23 op
311 9adeb265 2023-06-09 op kill $fcgi_pid
312 9adeb265 2023-06-09 op return 0
313 176179b2 2021-10-04 op }
314 176179b2 2021-10-04 op
315 176179b2 2021-10-04 op test_macro_expansion() {
316 176179b2 2021-10-04 op cat <<EOF > reg.conf
317 176179b2 2021-10-04 op pwd = "$PWD"
318 bb5a25d2 2024-01-30 op common = "lang it; auto index on"
319 176179b2 2021-10-04 op
320 176179b2 2021-10-04 op server "localhost" {
321 176179b2 2021-10-04 op # the quoting of \$ is for sh
322 80745f04 2023-08-29 op cert \$pwd "/localhost.pem"
323 80745f04 2023-08-29 op key \$pwd "/localhost.key"
324 176179b2 2021-10-04 op root \$pwd "/testdata"
325 5a345722 2023-06-23 op listen on $REGRESS_HOST port $port
326 bb5a25d2 2024-01-30 op @common
327 176179b2 2021-10-04 op }
328 176179b2 2021-10-04 op EOF
329 176179b2 2021-10-04 op
330 176179b2 2021-10-04 op if ! checkconf; then
331 176179b2 2021-10-04 op echo "failed to parse the config"
332 176179b2 2021-10-04 op return 1
333 176179b2 2021-10-04 op fi
334 176179b2 2021-10-04 op
335 176179b2 2021-10-04 op run
336 176179b2 2021-10-04 op
337 176179b2 2021-10-04 op fetch /
338 3524375a 2024-01-26 op check_reply "20 text/gemini;lang=it" "# hello world"
339 176179b2 2021-10-04 op }
340 176179b2 2021-10-04 op
341 4b5b1e82 2021-12-29 op test_proxy_relay_to() {
342 4b5b1e82 2021-12-29 op gen_config '' ''
343 92a9f41d 2022-01-03 op set_proxy ''
344 92a9f41d 2022-01-03 op
345 c064f3de 2022-01-01 op run
346 c064f3de 2022-01-01 op
347 c064f3de 2022-01-01 op ggflags="-P localhost:$port -H localhost.local"
348 c064f3de 2022-01-01 op
349 c064f3de 2022-01-01 op fetch /
350 c064f3de 2022-01-01 op check_reply "20 text/gemini" "# hello world"
351 c064f3de 2022-01-01 op }
352 c064f3de 2022-01-01 op
353 c064f3de 2022-01-01 op test_proxy_with_certs() {
354 92a9f41d 2022-01-03 op ggflags="-P localhost:$port -H localhost.local"
355 92a9f41d 2022-01-03 op
356 92a9f41d 2022-01-03 op # first test using the valid keys
357 92a9f41d 2022-01-03 op
358 c064f3de 2022-01-01 op gen_config '' 'require client ca "'$PWD'/testca.pem"'
359 92a9f41d 2022-01-03 op set_proxy "
360 92a9f41d 2022-01-03 op cert \"$PWD/valid.crt\"
361 92a9f41d 2022-01-03 op key \"$PWD/valid.key\"
362 92a9f41d 2022-01-03 op "
363 4b5b1e82 2021-12-29 op run
364 4b5b1e82 2021-12-29 op
365 92a9f41d 2022-01-03 op fetch /
366 92a9f41d 2022-01-03 op check_reply "20 text/gemini" "# hello world" || return 1
367 4b5b1e82 2021-12-29 op
368 92a9f41d 2022-01-03 op # then using some invalid keys
369 92a9f41d 2022-01-03 op
370 92a9f41d 2022-01-03 op gen_config '' 'require client ca "'$PWD'/testca.pem"'
371 92a9f41d 2022-01-03 op set_proxy "
372 80745f04 2023-08-29 op cert \"$PWD/invalid.pem\"
373 80745f04 2023-08-29 op key \"$PWD/invalid.key\"
374 92a9f41d 2022-01-03 op "
375 92a9f41d 2022-01-03 op run
376 92a9f41d 2022-01-03 op
377 4b5b1e82 2021-12-29 op fetch /
378 92a9f41d 2022-01-03 op check_reply "61 certificate not authorised" || return 1
379 92a9f41d 2022-01-03 op
380 92a9f41d 2022-01-03 op # and finally without keys
381 92a9f41d 2022-01-03 op
382 92a9f41d 2022-01-03 op gen_config '' 'require client ca "'$PWD'/testca.pem"'
383 92a9f41d 2022-01-03 op set_proxy ''
384 92a9f41d 2022-01-03 op run
385 92a9f41d 2022-01-03 op
386 92a9f41d 2022-01-03 op fetch /
387 92a9f41d 2022-01-03 op check_reply "60 client certificate required" || return 1
388 901905e0 2022-01-05 op }
389 901905e0 2022-01-05 op
390 901905e0 2022-01-05 op test_unknown_host() {
391 901905e0 2022-01-05 op setup_simple_test '' ''
392 901905e0 2022-01-05 op
393 901905e0 2022-01-05 op ggflags="-N -H foobar"
394 901905e0 2022-01-05 op fetch /
395 901905e0 2022-01-05 op check_reply '59 Wrong/malformed host or missing SNI'
396 4b5b1e82 2021-12-29 op }
397 fb121226 2022-02-26 op
398 fb121226 2022-02-26 op test_include_mime() {
399 fb121226 2022-02-26 op setup_simple_test "types { include '$PWD/example.mime.types' }" ""
400 fb121226 2022-02-26 op
401 fb121226 2022-02-26 op fetch_hdr /
402 91971201 2022-03-26 op check_reply '20 text/gemini' || return 1
403 fb121226 2022-02-26 op
404 fb121226 2022-02-26 op fetch_hdr /test.m3u8
405 91971201 2022-03-26 op check_reply '20 application/vnd.apple.mpegurl' || return 1
406 fb121226 2022-02-26 op
407 fb121226 2022-02-26 op fetch_hdr /foo.1
408 91971201 2022-03-26 op check_reply '20 text/x-mandoc' || return 1
409 60b4efa1 2023-07-24 op }
410 60b4efa1 2023-07-24 op
411 60b4efa1 2023-07-24 op test_log_file() {
412 60b4efa1 2023-07-24 op rm -f log log.edited
413 56054fe1 2023-08-03 op setup_simple_test '
414 56054fe1 2023-08-03 op log access "'$PWD'/log"
415 56054fe1 2023-08-03 op log style legacy'
416 60b4efa1 2023-07-24 op
417 60b4efa1 2023-07-24 op fetch_hdr /
418 60b4efa1 2023-07-24 op check_reply '20 text/gemini'
419 60b4efa1 2023-07-24 op
420 56054fe1 2023-08-03 op # remove the ip
421 56054fe1 2023-08-03 op awk '{$1 = ""; print substr($0, 2)}' log > log.edited
422 60b4efa1 2023-07-24 op
423 56054fe1 2023-08-03 op printf '%s\n' 'GET gemini://localhost/ 20 text/gemini' \
424 abd261d2 2023-07-25 op | cmp -s - log.edited
425 60b4efa1 2023-07-24 op if [ $? -ne 0 ]; then
426 60b4efa1 2023-07-24 op # keep the log for post-mortem analysis
427 60b4efa1 2023-07-24 op return 1
428 60b4efa1 2023-07-24 op fi
429 60b4efa1 2023-07-24 op
430 60b4efa1 2023-07-24 op rm -f log log.edited
431 60b4efa1 2023-07-24 op return 0
432 fb121226 2022-02-26 op }