Closed
Description
I create a Server with a FIFOBuffer Response body.
I have an async task that writes data to the FIFOBuffer once per second forever.
Rather than the client receiving an infinite stream of data, it only gets the first line, after which the server closes the connection.
It looks like maybe Base.write(io::IO, r::Union{Request, Response} ...)
should be doing while !eof(response.body) write(io, readavailable(response.body) end
?
Also, a content-length header is being returned even though the content is unknown (because the response FIFOBuffer has not been closed yet).
julia> server = HTTP.Server((req, rep) -> begin
io = HTTP.FIFOBuffer()
@async while true
println(io, "data: $(now())\n")
sleep(1)
end
r = Response(200, Dict(
"Content-Type" => "text/event-stream",
"Cache-Control" => "no-cache",
"Connection" => "keep-alive"
), io)
end, STDOUT)
julia> HTTP.serve(server)
$ curl 127.0.0.1:8081
data: 2017-08-22T22:00:04.988
$ curl 127.0.0.1:8081
data: 2017-08-22T22:00:05.635
Metadata
Metadata
Assignees
Labels
No labels