File: etag

package info (click to toggle)
weborf 1.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,152 kB
  • sloc: sh: 5,272; ansic: 3,505; python: 762; makefile: 119; xml: 44
file content (25 lines) | stat: -rwxr-xr-x 750 bytes parent folder | download
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
#!/bin/bash
. testsuite/functions.sh

PORT=12349
run_weborf -b site1 -p $PORT

# ETag header is there
curl -sv http://127.0.0.1:$PORT/robots.txt  |& grep ETag

ETAG=$(curl -sv http://127.0.0.1:$PORT/robots.txt  |& grep ETag | cut -d\  -f3 | tr -d '\r')

CACHED=$(curl -vs -H "If-None-Match: $ETAG" http://localhost:$PORT/robots.txt)
[[ $(printf $CACHED | wc -c) = 0 ]]


NON_CACHED=$(curl -vs -H 'If-None-Match: "aaaa"' http://localhost:$PORT/robots.txt)
[[ "$NON_CACHED" = $(cat site1/robots.txt) ]]


CACHED=$(curl -vs -H "If-Range: $ETAG" --range 0-3 http://localhost:$PORT/robots.txt)
[[ $(printf $CACHED | wc -c) = 4 ]]


CACHED=$(curl -vs -H 'If-Range: "qwe"' --range 0-3 http://localhost:$PORT/robots.txt)
[[ $(printf $CACHED | wc -c) != 4 ]]