From: jgart <jgart@dismail.de>
To: kaagum@systemreboot.net
Cc: jgart <jgart@dismail.de>
Subject: [PATCH] Remove #:streaming? #t from HTTP requests.
Date: Mon, 20 Jul 2026 15:21:50 +0100 [thread overview]
Message-ID: <20260720142610.1193079-2-jgart@dismail.de> (raw)
In-Reply-To: <20260720142610.1193079-1-jgart@dismail.de>
The #:streaming? #t option bypasses Guile's automatic content-encoding
decompression and chunked transfer decoding. This caused json->scm to
receive raw gzip-compressed bytes or trailing chunk framing data,
resulting in a json-invalid exception.
Without #:streaming? #t, http-request returns a clean bytevector that
we decode to a UTF-8 string and parse with json-string->scm.
The accept-encoding: identity workaround in openai-models is no longer
needed since Guile now handles gzip decompression automatically.
---
kaagum/openai.scm | 5 +++--
kaagum/web.scm | 9 +++------
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/kaagum/openai.scm b/kaagum/openai.scm
index 436a755..3334f3e 100644
--- a/kaagum/openai.scm
+++ b/kaagum/openai.scm
@@ -65,5 +65,6 @@ in @code{openai-query}."
(focus (key-ref "context_length") tree))))
(vector->list (focus (key-ref "data")
(json-get (uri-join base-uri "/v1/models")
- #:headers `((authorization
- . ,(string-append "Bearer " api-key))))))))
+ #:headers
+ `((authorization
+ . ,(string-append "Bearer " api-key))))))))
diff --git a/kaagum/web.scm b/kaagum/web.scm
index ce29bdd..3454b4b 100644
--- a/kaagum/web.scm
+++ b/kaagum/web.scm
@@ -23,6 +23,7 @@
#:use-module (web http)
#:use-module (web response)
#:use-module (json)
+ #:use-module (rnrs bytevectors)
#:export (uri-join
json-request
json-get
@@ -44,14 +45,10 @@ additional @var{headers}. Return JSON response."
(http-request url
#:method method
#:headers headers
- #:body body
- #:streaming? #t)))
- ;; Guile does not consider application/json responses as textual, and does
- ;; not automatically set the port encoding to UTF-8.
- (set-port-encoding! body "UTF-8")
+ #:body body)))
(case (quotient (response-code response)
100)
- ((2) (json->scm body))
+ ((2) (json-string->scm (utf8->string body)))
((4)
(raise-exception
(condition (make-violation)
--
2.55.0
next prev parent reply other threads:[~2026-07-20 14:26 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 14:21 [PATCH] Remove #:streaming? #t from HTTP requests to fix JSON parsing jgart
2026-07-20 14:21 ` jgart [this message]
2026-07-20 23:55 ` Arun Isaac
2026-07-21 8:51 ` jgart
2026-07-21 23:43 ` Arun Isaac
2026-07-22 3:31 ` jgart
2026-07-22 11:03 ` Arun Isaac
2026-08-14 11:52 ` jgart
2026-08-14 13:01 ` Arun Isaac
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260720142610.1193079-2-jgart@dismail.de \
--to=jgart@dismail.de \
--cc=kaagum@systemreboot.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox