]> git.plutz.net Git - cgilite/blobdiff - static.sh
forking cgilite into separate project
[cgilite] / static.sh
diff --git a/static.sh b/static.sh
deleted file mode 100755 (executable)
index bf109ed..0000000
--- a/static.sh
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/bin/zsh
-
-# Copyright 2016 Paul Hänsch
-#
-# This file is part of shcgi.
-# 
-# shcgi is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# shcgi is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU Affero General Public License for more details.
-# 
-# You should have received a copy of the GNU Affero General Public License
-# along with shcgi.  If not, see <http://www.gnu.org/licenses/>. 
-
-
-unset length date file suffix
-file="$1"
-date="$(stat -Lc %Y "$file")"
-
-# allow overriding magic file recognition
-# don't use this if `file` returns type correctly
-declare -A suffix
-suffix[css]="text/css"
-
-[ -n "$HTTP_IF_MODIFIED_SINCE" ] && cachedate="$(date -d "$HTTP_IF_MODIFIED_SINCE" +%s)"
-
-if printf '%s' "${HTTP_RANGE}" |grep -qE '^bytes=[0-9]+-[0-9]*\r?$'; then
-  _range="${HTTP_RANGE#bytes=}"
-  _bstart="${_range%-*}"
-  _bend="${_range#*-}"
-fi
-
-if ! [ -f "$file" ] || [ -x "$file" ] || ! grep -qm1 '' "$file" ; then
-  printf 'Status:403 Forbidden\r\n\r\n'
-elif [ "$date" = "$cachedate" ]; then
-  printf 'Status:304 Not Modified\r\n'
-  printf 'Last-Modified: %s\r\n\r\n' "$(date -Rd "@$date")"
-elif [ "$_bstart" -gt 0 ] ; then
-  length="$(stat -Lc %s "$file")"
-  magic="${suffix[${file##*.}]:-$(file -bi "$file")}"
-
-  printf 'Status:206 Partial Content\r\n'
-  printf 'Last-Modified: %s\r\n' "$(date -Rd "@$date")"
-  printf 'Content-Type: %s\r\n' "${magic:-all/all}"
-  printf 'Content-Range: bytes %i-%i/%i\r\n' $_bstart $(($length - 1)) $length |debug
-  printf 'Content-Length: %i\r\n' $(($length - $_bstart))
-  printf '\r\n'
-
-  tail -c+"$(($_bstart + 1))" "$file"
-else
-  length="$(stat -Lc %s "$file")"
-  magic="${suffix[${file##*.}]:-$(file -bi "$file")}"
-
-  printf 'Accept-Ranges: bytes\r\n'
-  printf 'Last-Modified: %s\r\n' "$(date -Rd "@$date")"
-  printf 'Content-Type: %s\r\n' "${magic:-all/all}"
-  printf 'Content-Length: %i\r\n' "$length"
-  printf '\r\n'
-
-  cat "$file"
-fi
-