summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
35f560d)
svn path=/trunk/; revision=41
+ s;^(\r?\n)*;;;
+ s;([^\r])\n;\1\r\n;g;
- /^HTTP\/[0-9]\.[0-9] [1-5][0-9][0-9] .*/bX
+ /^Status: *[1-5][0-9][0-9] .*/{s;^Status: *;HTTP/1.1 ;; bX}
s;^(.+\n)?Location: .*$;HTTP/1.1 302 Found\r\n&;
s;^(.+\n)?Content-Type: .*$;HTTP/1.1 200 OK\r\n&;
s;^(.+\n)?Location: .*$;HTTP/1.1 302 Found\r\n&;
s;^(.+\n)?Content-Type: .*$;HTTP/1.1 200 OK\r\n&;
declare -A suffix
suffix[css]="text/css"
declare -A suffix
suffix[css]="text/css"
+[ -n "$HTTP_IF_MODIFIED_SINCE" ] && cachedate="$(date -d "$HTTP_IF_MODIFIED_SINCE" +%s)"
+
if [ -x "$file" -o \! -r "$file" -o \! -f "$file" ]; then
if [ -x "$file" -o \! -r "$file" -o \! -f "$file" ]; then
- printf 'HTTP/1.1 403 Forbidden\r\n\r\n'
-elif [ "$date" = "$HTTP_IF_NONE_MATCH" ]; then
- printf 'HTTP/1.1 304 Not Modified\r\n'
- printf 'Etag: %s\r\n\r\n' "$date"
+ printf 'Status:403 Forbidden\r\n\r\n'
+elif [ "$date" = "$cachedate" ]; then
+ debug "Delegating to client cache"
+ printf 'Status:304 Not Modified\r\n'
+ printf 'Last-Modified: %s\r\n\r\n' "$(date -Rd "@$date")"
else
length="$(stat -c %s "$file")"
magic="${suffix[${file##*.}]:-$(file -bi "$file")}"
else
length="$(stat -c %s "$file")"
magic="${suffix[${file##*.}]:-$(file -bi "$file")}"
- printf 'Etag: %s\r\n' "$date"
+ printf 'Last-Modified: %s\r\n' "$(date -Rd "@$date")"
printf 'Content-Type: %s\r\n' "${magic:-all/all}"
printf 'Content-Length: %s\r\n' "$length"
printf '\r\n'
printf 'Content-Type: %s\r\n' "${magic:-all/all}"
printf 'Content-Length: %s\r\n' "$length"
printf '\r\n'