summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/simple/htgen-cyberlocker/src
diff options
context:
space:
mode:
Diffstat (limited to 'krebs/5pkgs/simple/htgen-cyberlocker/src')
-rw-r--r--krebs/5pkgs/simple/htgen-cyberlocker/src/htgen-cyberlocker23
1 files changed, 21 insertions, 2 deletions
diff --git a/krebs/5pkgs/simple/htgen-cyberlocker/src/htgen-cyberlocker b/krebs/5pkgs/simple/htgen-cyberlocker/src/htgen-cyberlocker
index 5ca0ddd3e..d04b4b1f0 100644
--- a/krebs/5pkgs/simple/htgen-cyberlocker/src/htgen-cyberlocker
+++ b/krebs/5pkgs/simple/htgen-cyberlocker/src/htgen-cyberlocker
@@ -5,6 +5,13 @@ emptyok_response() {(
printf '\r\n'
)}
+not_modifed_response() {(
+ printf "HTTP/1.1 304 Not Modified\r\n"
+ printf 'Connection: close\r\n'
+ printf 'Server: %s\r\n' "$Server"
+ printf '\r\n'
+)}
+
delete_response() {
jq -n -r \
--arg server "$Server" \
@@ -74,8 +81,20 @@ case "$Method $path" in
'GET /'*)
item=$STATEDIR/items/$(echo "$path" | jq -rR @uri)
if [ -e "$item" ]; then
- file_response "$item"
- exit
+ if [ -z ${req_if_modified_since+x} ]; then
+ file_response "$item"
+ exit
+ else
+ age_file=$(date +%s -r "$item")
+ age_header=$(date +%s --date="$req_if_modified_since")
+ if [ "$age_file" -lt "$age_header" ]; then
+ not_modifed_response
+ exit
+ else
+ file_response "$item"
+ exit
+ fi
+ fi
fi
;;
'DELETE /'*)