summaryrefslogtreecommitdiff
path: root/http-client.scm
diff options
context:
space:
mode:
authorPeter Bex <peter@more-magic.net>2026-09-01 11:24:03 +0200
committerPeter Bex <peter@more-magic.net>2026-09-01 11:24:03 +0200
commit26539363e59b04f47c2f8b60e1af90144b95f0c9 (patch)
treeace0e996907be61d7b635e0be1fdf212cc422483 /http-client.scm
parent3338e5a067e00789e50ee57b5635c55371e4cec0 (diff)
downloadhttp-client-26539363e59b04f47c2f8b60e1af90144b95f0c9.tar.gz
Fix read-bytevector argument count in make-delimited-input-port2.0.1
Similar to the 7c9edbf change in intarweb 3.0.1: In CHICKEN 6.0.0, the signature was documented to be different, but we were using the actual signature. For later CHICKEN versions, the signature was updated to match the documentation so now we're kind of stuck having to support both signatures. Since we cannot cond-expand our way out of this because there are no features that differ between 6.0.0 and 6.0.1, we'll have to use case-lambda and convert the old signature to the new one. Oh well...
Diffstat (limited to 'http-client.scm')
-rw-r--r--http-client.scm20
1 files changed, 14 insertions, 6 deletions
diff --git a/http-client.scm b/http-client.scm
index e6c8831..2d5e182 100644
--- a/http-client.scm
+++ b/http-client.scm
@@ -46,7 +46,7 @@
server-connector default-server-connector
prepare-request default-prepare-request)
-(import scheme (scheme base)
+(import scheme (scheme base) (scheme case-lambda)
srfi-1 srfi-13 srfi-18 srfi-69
(chicken base) (chicken string) (chicken time)
(chicken sort) (chicken io) (chicken file posix) (chicken format)
@@ -283,6 +283,18 @@
(if (not len)
port ;; no need to delimit anything
(let ((pos 0))
+ ;; NOTE: This is using case-lambda because the signature changed between CHICKEN 6.0.0 and later releases
+ ;; In 6.0.0 it receives the port and the the number of bytes to read so we have to convert that old
+ ;; signature to the newer signature.
+ (define read-bytevector/pos
+ (case-lambda
+ ((p bytes buf off)
+ (read-bytevector/pos buf off (+ bytes off)))
+ ((buf start end)
+ (let* ((bytes (min (- end start) (- len pos)))
+ (bytes-read (read-bytevector! buf port start (+ start bytes))))
+ (set! pos (+ pos bytes-read))
+ bytes-read))))
(make-input-port
(lambda () ; read-char
(if (= pos len)
@@ -298,11 +310,7 @@
(if (= pos len)
#!eof
(peek-char port)))
- read-bytevector: (lambda (p bytes buf off)
- (let* ((bytes (min bytes (- len pos)))
- (bytes-read (read-bytevector! buf port off (+ off bytes))))
- (set! pos (+ pos bytes-read))
- bytes-read))
+ read-bytevector: read-bytevector/pos
read-line: (lambda (p limit)
(if (= pos len)
#!eof