From 5f8cd2dc5642ce99a535ea6b3001a359096d6975 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 16 Jul 2024 17:16:22 +0100 Subject: Stream the package derivation page since it can be large --- guix-data-service/web/compare/controller.scm | 3 ++- guix-data-service/web/render.scm | 16 +++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/guix-data-service/web/compare/controller.scm b/guix-data-service/web/compare/controller.scm index 901b4f9..e1fab78 100644 --- a/guix-data-service/web/compare/controller.scm +++ b/guix-data-service/web/compare/controller.scm @@ -748,7 +748,8 @@ (valid-targets->options targets) build-status-strings build-server-urls - derivation-changes)))))))))))) + derivation-changes) + #:stream? #t))))))))))) (define (render-compare-by-datetime/package-derivations mime-types query-parameters) diff --git a/guix-data-service/web/render.scm b/guix-data-service/web/render.scm index 1ec47ac..90f577e 100644 --- a/guix-data-service/web/render.scm +++ b/guix-data-service/web/render.scm @@ -139,17 +139,23 @@ #f))) (define* (render-html #:key sxml (extra-headers '()) - (code 200)) + (code 200) + stream?) (list (build-response #:code code #:headers (append extra-headers '((content-type . (text/html (charset . "utf-8"))) (vary . (accept))))) - (call-with-encoded-output-string - "utf-8" - (lambda (port) - (sxml->html sxml port))))) + (if stream? + (lambda (port) + (set-port-encoding! port "utf-8") + (setvbuf port 'block (expt 2 20)) + (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) -- cgit v1.2.3