summaryrefslogtreecommitdiff
path: root/simple-directory-handler.scm
diff options
context:
space:
mode:
authorPeter Bex <peter@more-magic.net>2026-10-05 13:07:22 +0200
committerPeter Bex <peter@more-magic.net>2026-10-05 13:07:22 +0200
commit136d2d65ecdf77e5ced5b22e9c26bdc3c6ccf971 (patch)
tree2297816e9aecce7cb8b762a4d61ff345aceadaf1 /simple-directory-handler.scm
parent27d3f7f02ea626b90edab4280b3b143a4b2e340d (diff)
downloadspiffy-6.5.tar.gz
Fix content-length to use byte count instead of char count on C66.5
Also, default to utf-8 charsets in default mime type map and default response headers and when sending status responses and in the simple directory handler.
Diffstat (limited to 'simple-directory-handler.scm')
-rw-r--r--simple-directory-handler.scm11
1 files changed, 8 insertions, 3 deletions
diff --git a/simple-directory-handler.scm b/simple-directory-handler.scm
index 47dbea9..68b93e8 100644
--- a/simple-directory-handler.scm
+++ b/simple-directory-handler.scm
@@ -41,9 +41,14 @@
(only srfi-14 char-set-complement char-set-delete))
(cond-expand
- (chicken-6 (import (scheme base))) ; For make-parameter, which moved from (chicken base)
+ (chicken-6 (import (scheme base) (chicken memory representation))) ; For make-parameter, which moved from (chicken base)
(else))
+(define (string-byte-length s)
+ (cond-expand
+ (chicken-6 (number-of-bytes s))
+ (else (string-length s))))
+
(define (encode-path p)
(let ((cs (char-set-delete (char-set-complement char-set:uri-unreserved) #\/)))
(uri-encode-string p cs)))
@@ -108,8 +113,8 @@
((exn i/o file) str))))
""
dir)))))
- (with-headers `((content-type text/html)
- (content-length ,(string-length str)))
+ (with-headers `((content-type #(text/html ((charset . utf-8))))
+ (content-length ,(string-byte-length str)))
(lambda ()
(write-logged-response)
(unless (eq? 'HEAD (request-method (current-request)))