[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Adjust render procedures to not use procedures fo
From: |
Christopher Baines |
Subject: |
branch master updated: Adjust render procedures to not use procedures for responses |
Date: |
Thu, 09 Feb 2023 06:50:40 -0500 |
This is an automated email from the git hooks/post-receive script.
cbaines pushed a commit to branch master
in repository data-service.
The following commit(s) were added to refs/heads/master by this push:
new 6be113f Adjust render procedures to not use procedures for responses
6be113f is described below
commit 6be113f99d52cc284ecd0ed07fc88df5ea7bf718
Author: Christopher Baines <mail@cbaines.net>
AuthorDate: Thu Feb 9 11:43:42 2023 +0000
Adjust render procedures to not use procedures for responses
The newer Guile Fibers web server will use the chunked transfer encoding
when
a procedure is used and the content length is unspecified. This is good for
large responses, but unnecessary here. Also, there's a bug with the charset
so
these changes to respond with correctly encoded bytevectors to avoid that.
---
guix-data-service/web/render.scm | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/guix-data-service/web/render.scm b/guix-data-service/web/render.scm
index 081399a..744c66c 100644
--- a/guix-data-service/web/render.scm
+++ b/guix-data-service/web/render.scm
@@ -24,6 +24,7 @@
#:use-module (srfi srfi-19)
#:use-module (srfi srfi-26)
#:use-module (ice-9 ftw)
+ #:use-module (ice-9 iconv)
#:use-module (ice-9 binary-ports)
#:use-module (web request)
#:use-module (web response)
@@ -142,30 +143,39 @@
(list (build-response
#:code code
#:headers (append extra-headers
- '((content-type . (text/html))
+ '((content-type . (text/html
+ (charset . "utf-8")))
(vary . (accept)))))
- (lambda (port)
- (sxml->html sxml port))))
+ (call-with-encoded-output-string
+ "utf-8"
+ (lambda (port)
+ (sxml->html sxml port)))))
(define* (render-json json #:key (extra-headers '())
(code 200))
(list (build-response
#:code code
#:headers (append extra-headers
- '((content-type . (application/json))
+ '((content-type . (application/json
+ (charset . "utf-8")))
(vary . (accept)))))
- (lambda (port)
- (scm->json json port))))
+ (call-with-encoded-output-string
+ "utf-8"
+ (lambda (port)
+ (scm->json json port)))))
(define* (render-text text #:key (extra-headers '())
(code 200))
(list (build-response
#:code code
#:headers (append extra-headers
- '((content-type . (text/plain))
+ '((content-type . (text/plain
+ (charset . "utf-8")))
(vary . (accept)))))
- (lambda (port)
- (display text port))))
+ (call-with-encoded-output-string
+ "utf-8"
+ (lambda (port)
+ (display text port)))))
(define (not-found uri)
(list (build-response #:code 404)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Adjust render procedures to not use procedures for responses,
Christopher Baines <=