ocaml-cohttp icon indicating copy to clipboard operation
ocaml-cohttp copied to clipboard

provide raw/unbuffered channels

Open edwintorok opened this issue 10 years ago • 2 comments

The input channel is always buffered and the Lwt_stream (or underlying Lwt_io from Conduit) doesn't have a way to "give me whatever is available now" without blocking/waiting for a fixed amount of bytes. This can be problematic if you want to implement CONNECT for example. There should be a way to switch the input channel from buffered to unbuffered mode.

On output this is not much of a problem because you can just flush it, although when sending a response from a file the source is already buffered, and the buffering on the destination seems redundant.

edwintorok avatar Jun 03 '15 08:06 edwintorok

@djs55 also has a need for this to pass the fd around to another process once the headers are read. I think that Lwt_io might need to be extended to access the buffer though...

On 3 Jun 2015, at 09:32, Török Edwin [email protected] wrote:

The input channel is always buffered and the Lwt_stream (or underlying Lwt_io from Conduit) doesn't have a way to "give me whatever is available now" without blocking/waiting for a fixed amount of bytes. This can be problematic if you want to implement CONNECT for example. There should be a way to switch the input channel from buffered to unbuffered mode.

On output this is not much of a problem because you can just flush it, although when sending a response from a file the source is already buffered, and the buffering on the destination seems redundant.

— Reply to this email directly or view it on GitHub https://github.com/mirage/ocaml-cohttp/issues/367.

avsm avatar Jun 04 '15 00:06 avsm

It's already possible (but painful) to manipule raw channels. See https://github.com/mirage/ocaml-git/blob/master/lib/http/git_http.ml#L183 Exposing helpers for doing this would be helpful.

samoht avatar Jun 04 '15 07:06 samoht