Skip to content

Commit

Permalink
Read text resource into octets first, then convert to text
Browse files Browse the repository at this point in the history
  • Loading branch information
borodust committed Apr 17, 2020
1 parent 5ba6cb1 commit 0637425
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions resources/handler.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,15 @@

(defmethod decode-resource ((this text-resource-handler) stream)
(with-slots (encoding) this
(let ((string-stream (flex:make-flexi-stream stream :external-format encoding)))
(read-stream-content-into-string string-stream))))
;; FIXME: this is suboptimal, but flexi stream doesn't seem to handle
;; buffered read very well and throws errors like
;; `Unexpected value #x89 at start of UTF-8 sequence.`
;; if you try to read from it in chunks
;;
;; Need to somehow get back to buffered reading with
;; (flex:make-flexi-stream stream :external-format encoding)
(flexi-streams:octets-to-string (read-stream-content-into-byte-vector stream)
:external-format encoding)))


(defmethod encode-resource ((this text-resource-handler) (resource string) stream)
Expand Down

0 comments on commit 0637425

Please sign in to comment.