From b4d03834ec4e2687a03c4fb92f27c98dc3bbf986 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Tue, 25 Apr 2017 22:51:31 -0700 Subject: [PATCH] Eliminate "output-octets" instance. --- src/ssp/mod-lisp.scm | 49 ++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/src/ssp/mod-lisp.scm b/src/ssp/mod-lisp.scm index c3d349124..a7db288cc 100644 --- a/src/ssp/mod-lisp.scm +++ b/src/ssp/mod-lisp.scm @@ -384,26 +384,35 @@ USA. (set-status-header response code) (set-content-type-header response 'text/html) (set-entity response - (call-with-output-octets - (lambda (port) - (write-xml - (let ((message (status-message code))) - (html:html #f - "\n" - (html:head #f - "\n" - (html:title #f code " " message) - "\n") - "\n" - (html:body #f - "\n" - (html:h1 #f message) - "\n" - extra - "\n") - "\n")) - port) - (newline port))))) + (bytevector->string + (call-with-output-bytevector + (lambda (port) + (write-xml + (let ((message (status-message code))) + (html:html #f + "\n" + (html:head #f + "\n" + (html:title #f code " " message) + "\n") + "\n" + (html:body #f + "\n" + (html:h1 #f message) + "\n" + extra + "\n") + "\n")) + port) + (newline port)))))) + +(define (bytevector->string bv) + (let* ((n (bytevector-length bv)) + (builder (string-builder))) + (do ((i 0 (fix:+ i 1))) + ((not (fix:< i n))) + (builder (integer->char (bytevector-u8-ref bv i)))) + (builder))) (define (set-status-header message code) (set-header message -- 2.25.1