Closed informatimago closed 1 year ago
Note, in the docs:
If you want to read binary data from this stream, read from the underlying stream which you can get with FLEXI-STREAM-STREAM.
https://edicl.github.io/drakma/#arg-force-binary
I hope this work for writing too.
(Maybe you have a valid point about flexi-stream with element type octect, I am not sure. Although since the doc explicitly suggests the underlying stream for binary IO, it may be by design. At least working with the underlying stream is a workaround for your code.)
An answer on the flexi-stream issue explains it. https://github.com/edicl/flexi-streams/issues/49
The problem is that flexi-stream interprets a buffer vector of T (or not vector of integer) as non-binary, without looking at the contents of the vector. If we don't pass a buffer vector of integer, it expects characters inside. So we have to copy the buffers to vectors of octets to have it take the binary data.
This means that I have a work-around, but it may be rather costly when we use flexi-stream (and therefore when we use drakma that uses flexi-stream).
The problem is not directly in drakma, but since it uses flexi-stream explicitely in its API, I think the documentation should mention that when working on the http stream, we're restricted to vectors of bytes to send and receive binary data.
Therefore this issue could be converted in a documentation update issue for drakma and be closed. Thank you.
@informatimago, you've probably missed the comment above. Writing through the underlying stream may save from the need to copy buffers.
Ah, it's a possibility. I will try it and report.
@avodonosov it works indeed using the underlying stream. It's a better solution. Thank you.
I'm trying to get a binary stream, but drakma always opens a latin-1 stream
So when I try to write a sequence of bytes, the flexistream complains:
I reported also the issue to flexi-stream, https://github.com/edicl/flexi-streams/issues/49 since from the name flexi-stream I would also have expected an ambivalent stream, but perhaps it's not how it's supposed to work.