diff --git a/test/WebSockets.jl b/test/WebSockets.jl index 303e9310e..eed1ac686 100644 --- a/test/WebSockets.jl +++ b/test/WebSockets.jl @@ -25,4 +25,35 @@ for s in ["ws", "wss"] end +@async HTTP.listen(ip"127.0.0.1",8000) do http + if HTTP.WebSockets.is_websocket_upgrade(http.message) + HTTP.WebSockets.upgrade(http) do client + data = "" + while !eof(client); + data = String(readavailable(client)) + end + write(client,data) + end + end +end + +sleep(2) + +HTTP.WebSockets.open("ws://127.0.0.1:8000") do io + write(io, HTTP.bytes("Foo")) + @test !eof(io) + @test String(readavailable(io)) == "Foo" + + write(io, HTTP.bytes("Hello")) + write(io, " There") + write(io, " World", "!") + closewrite(io) + + buf = IOBuffer() + write(buf, io) + @test String(take!(buf)) == "Hello There World!" + + close(io) +end + end # testset