Follow bytes->string returning a Result

- A device file whose document is not UTF-8 is an error: "the document
  in it is not UTF-8".
- A page title that does not decode in its charset is read as
  Windows-1252, by matching the result rather than catching.
- Hex digits, charset names and the tests' response heads are read with
  bytes->string/lossy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Linus Björnstam 2026-11-23 14:01:18 +01:00
parent 6fc668e908
commit f7abd8ebe1
5 changed files with 8 additions and 7 deletions

View file

@ -63,7 +63,7 @@
(if (string-contains? seen "\r\n\r\n")
(match (string-split-once seen "\r\n") ((Some (Tuple l _)) l) (None seen))
(match (read-some in)
((Some bs) (go (str seen (bytes->string bs))))
((Some bs) (go (str seen (bytes->string/lossy bs))))
(None seen)))))
;; One connection: one request, one answer. The wait ends early when the