-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cohttp-eio: expose the underlying flow additionally to Buf_write when sending the response body #970
Comments
Not sure but for your particular use-case can |
The link says:
What you can do is use I'm not sure providing the raw sink will work, because we'll still typically need to do chunking. What are you planning to use it for? |
I wanted to fix this TODO in
When serving files over HTTP, it's useful to be able to manipulate the flow so that a single let respond_file fname =
...
let headers = Http.Header.of_list
[ "content-type", mime_type;
"content-length", string_of_int length;
] in
let response =
Http.Response.make ~version:`HTTP_1_1 ~status:`OK ~headers ()
in
response, Body.Flow (fun flow ->
Eio.Path.with_open_in fname @@ fun file ->
Eio.Flow.copy file flow) without having to resort to the chunked encoding. |
Currently the body type is:
I believe it would be nice to have an additional body type that enables to write directly into the connection flow.
This way, one can use
Eio.Flow.copy
to send a file in a streaming fashion. I believe that using Buf_write would require writing the full content in the buffer, right ?The text was updated successfully, but these errors were encountered: