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:
parent
19b19fb83f
commit
7952b1fe03
1 changed files with 4 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue