io/copy: drain a byte-input-stream shim source

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.
This commit is contained in:
Yogthos 2026-06-25 09:01:02 -04:00
parent 19b19fb83f
commit 7952b1fe03

View file

@ -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))) (cond ((in-stream? input) (let ((bv (get-bytevector-all (in-stream-port input)))) (if (eof-object? bv) (make-bytevector 0) bv)))
((bytevector? input) input) ((bytevector? input) input)
((and (jolt-array? input) (eq? (jolt-array-kind input) 'byte)) (na-bytearray->bv 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))) (else #f)))
(define (input-text input) (define (input-text input)
(cond ((string? input) input) (cond ((string? input) input)