From 7952b1fe030eb696ad53e0ca313c3d447a5e4156 Mon Sep 17 00:00:00 2001 From: Yogthos Date: Thu, 25 Jun 2026 09:01:02 -0400 Subject: [PATCH] io/copy: drain a byte-input-stream shim source MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit input-bytes handled in-stream/bytevector/byte-array sources but not a host byte-input-stream table (:jolt/input-stream — http-client's ByteArrayInputStream), so io/copy fell through to rendering it as text (#[chez-htable …]) instead of its bytes. Drain it like slurp does. Fixes http-client's response-body handling (jolt-bjbi): its suite goes 100/16-fail -> 116/0, and the ring adapter's. --- host/chez/io-streams.ss | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/host/chez/io-streams.ss b/host/chez/io-streams.ss index 3eb9782..98849b2 100644 --- a/host/chez/io-streams.ss +++ b/host/chez/io-streams.ss @@ -275,6 +275,10 @@ (cond ((in-stream? input) (let ((bv (get-bytevector-all (in-stream-port input)))) (if (eof-object? bv) (make-bytevector 0) bv))) ((bytevector? input) input) ((and (jolt-array? input) (eq? (jolt-array-kind input) 'byte)) (na-bytearray->bv input)) + ;; a byte-input-stream shim (host tagged-table, :jolt/input-stream — e.g. + ;; http-client's ByteArrayInputStream): drain it byte-exact, like slurp. + ((and (htable? input) (jolt-truthy? (jolt-ref-get input (keyword "jolt" "input-stream")))) + (drain-byte-stream input)) (else #f))) (define (input-text input) (cond ((string? input) input)