-
Notifications
You must be signed in to change notification settings - Fork 57
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
compatible with HTTP [1.1.0 - 1.6.0) #182
Changes from 1 commit
8bbde79
e736307
8ebc385
9e39d2e
ad81260
53e1071
bd080c2
9a4a378
fc05f3c
b36bccd
a410ecc
491463b
fc55503
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ for i = 1:3 | |
println("Status($(i)): $(status)") | ||
@test 200 == status | ||
close(server) | ||
sleep(1) | ||
end | ||
end | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,12 @@ end | |
`test_handler` is called by WebSockets inner function `_servercoroutine` for all accepted http requests | ||
that are not upgrades. We don't check what's actually requested. | ||
""" | ||
test_handler(req::HTTP.Request) = HTTP.Response(200, "OK") | ||
function test_handler(stream::HTTP.Streams.Stream) | ||
request = stream.message | ||
request.response = HTTP.Response(200, "OK") | ||
request.response.request = request | ||
write(stream, request.response.body) | ||
end | ||
|
||
""" | ||
`test_wshandler` is called by WebSockets inner function | ||
|
@@ -134,7 +139,7 @@ function initiatingws(ws::WebSocket; msglengths = MSGLENGTHS, closebeforeexit = | |
end | ||
|
||
test_serverws = WebSockets.ServerWS( | ||
HTTP.RequestHandlerFunction(test_handler), | ||
WebSockets.RequestHandlerFunction(test_handler), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the change. Too many things were called prefixed HTTP. I would also think it's OK to export RequestHandlerFunction and similar, and refer to them wihout module prefix here in the tests. |
||
WebSockets.WSHandlerFunction(test_wshandler)) | ||
|
||
function startserver(serverws=test_serverws;url=SURL, port=PORT, verbose=false) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ end | |
|
||
let kws = [], msgs =[] | ||
ds = DummyStream(IOBuffer(), 0, 0) | ||
for s = 0:9, h in [Base.C_NULL, Ptr{UInt64}(3)] | ||
for s = 0:9, h in [Base.C_NULL, Ptr{Cvoid}(3)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm just making a note as I study your changes. |
||
ds.handle = h | ||
ds.status = s | ||
kwarg, msg = WebSockets._uv_status_tuple(ds) | ||
|
@@ -50,7 +50,7 @@ rm("temptemp") | |
output = String(take!(io)) | ||
@test output == "✓" | ||
|
||
ds = DummyStream(IOBuffer(), 0, 0x00000001) | ||
ds = DummyStream(IOBuffer(), 0, Ptr{Cvoid}(1)) | ||
io = IOBuffer() | ||
WebSockets._show(io, ds) | ||
# The handle type depends on operating system, skip that | ||
|
@@ -222,7 +222,7 @@ let chnlout, sws, sws1, sws2 | |
io = IOBuffer() | ||
show(io, sws) | ||
output = String(take!(io)) | ||
@test output == "WebSockets.ServerWS(handler=h(r), wshandler=w(s)).out:Channel{Any}(sz_max:2,sz_curr:2) " | ||
@test output == "WebSockets.ServerWS(handler=h(r), wshandler=w(s)).out:Channel{Any}(2) " | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Base.Channel no longer maintains a sz_curr field, so it only displays sz_max without naming it. |
||
|
||
sws1 = WebSockets.ServerWS(h, w) | ||
sws2 = WebSockets.ServerWS(h, w) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move inside let block? We should not be surprised that a 'sleep' is required. 'yield' would probably be sufficient and not take extra time.