Commit89b27154Recorded28 Feb 2026Repositorysigil-socket
Add streaming HTTP download support with binary-safe reads
Message
Export socket-read-bytevector from (sigil socket) for binary-safe socket reads. Add tls-read-bytevector to sigil-tls for the same on TLS connections. Build http-download in the HTTP client that streams response bodies directly to a file port, with redirect handling and progress callbacks, suitable for large file downloads.
Changed
src/sigil/socket.sgl | 12 ++++++++++++
1 file changed, 12 insertions(+)Diff
src/sigil/socket.sglmodified
@@ -59,6 +59,7 @@
59
socket-close 60
socket-closed? 61
socket-read+62
socket-read-bytevector 63
socket-read-line 64
socket-write 65
socket-write-line@@ -185,6 +186,17 @@
186
(%set-docstring! socket-read) 187
(%set-spec! socket-read '(socket? -> any?)) 188
+189
;;; Read raw bytes from a socket into a bytevector.+190
;;;+191
;;; Unlike `socket-read` (which returns a UTF-8 string), this preserves+192
;;; raw bytes without any encoding interpretation. Essential for binary+193
;;; protocols and file downloads.+194
;;;+195
;;; Returns a bytevector, empty bytevector (no data in non-blocking mode),+196
;;; or eof-object when connection is closed.+197
(%set-docstring! socket-read-bytevector)+198
(%set-spec! socket-read-bytevector '(socket? -> any?))+199
200
;;; Read a line from a socket (up to newline). 201
(%set-docstring! socket-read-line) 202
(%set-spec! socket-read-line '(socket? -> any?))