summaryrefslogtreecommitdiff
path: root/http.tcl
diff options
context:
space:
mode:
authoralekseiplusplus <alekseijeaves@protonmail.com>2024-06-29 20:27:11 +1000
committeralekseiplusplus <alekseijeaves@protonmail.com>2024-06-29 20:27:11 +1000
commita61f03cfbf62eb006e6bd845694f18d40101d4e8 (patch)
tree30c7a00c956e61ed2c54c4893cb449eae5bf55da /http.tcl
parent252ad2b3446457e95fb7bb41829bc24304090232 (diff)
Added cache
Diffstat (limited to 'http.tcl')
-rwxr-xr-xhttp.tcl14
1 files changed, 8 insertions, 6 deletions
diff --git a/http.tcl b/http.tcl
index 68cb163..307aebf 100755
--- a/http.tcl
+++ b/http.tcl
@@ -103,13 +103,15 @@ namespace eval http {
# Sends an opened file or cached file.
proc send-file {channel filename} {
- #TODO: configure it to try the cache.
- #TODO: configure channels to use binary translation if content type is not text/*
- set file [open $filename]
- fconfigure $file -translation binary
fconfigure $channel -translation binary
- fcopy $file $channel
- close $file
+ if [cache::hit $filename] {
+ puts $channel [cache::get $filename]
+ } else {
+ set file [open $filename]
+ fconfigure $file -translation binary
+ fcopy $file $channel
+ close $file
+ }
}
## Header