mirror of
https://github.com/logos-storage/nim-websock.git
synced 2026-01-07 16:13:08 +00:00
parent
781cb35200
commit
7e668c4c85
@ -25,6 +25,9 @@ requires "bearssl"
|
|||||||
requires "https://github.com/status-im/nim-zlib"
|
requires "https://github.com/status-im/nim-zlib"
|
||||||
|
|
||||||
task test, "run tests":
|
task test, "run tests":
|
||||||
|
# dont't need to run it, only want to test if it is compileable
|
||||||
|
exec "nim c -c --verbosity:0 --hints:off -d:chronicles_log_level=TRACE -d:chronicles_sinks:json ./tests/testcommon"
|
||||||
|
|
||||||
exec "nim --hints:off c -r --opt:speed -d:debug --verbosity:0 --hints:off -d:chronicles_log_level=info ./tests/testcommon.nim"
|
exec "nim --hints:off c -r --opt:speed -d:debug --verbosity:0 --hints:off -d:chronicles_log_level=info ./tests/testcommon.nim"
|
||||||
rmFile "./tests/testcommon"
|
rmFile "./tests/testcommon"
|
||||||
|
|
||||||
|
|||||||
@ -38,13 +38,13 @@ proc validateRequest(
|
|||||||
##
|
##
|
||||||
|
|
||||||
if header.meth notin {MethodGet}:
|
if header.meth notin {MethodGet}:
|
||||||
trace "GET method is only allowed", address = stream.tsource.remoteAddress()
|
trace "GET method is only allowed", address = $stream.tsource.remoteAddress()
|
||||||
await stream.sendError(Http405, version = header.version)
|
await stream.sendError(Http405, version = header.version)
|
||||||
return ReqStatus.Error
|
return ReqStatus.Error
|
||||||
|
|
||||||
var hlen = header.contentLength()
|
var hlen = header.contentLength()
|
||||||
if hlen < 0 or hlen > MaxHttpRequestSize:
|
if hlen < 0 or hlen > MaxHttpRequestSize:
|
||||||
trace "Invalid header length", address = stream.tsource.remoteAddress()
|
trace "Invalid header length", address = $stream.tsource.remoteAddress()
|
||||||
await stream.sendError(Http413, version = header.version)
|
await stream.sendError(Http413, version = header.version)
|
||||||
return ReqStatus.Error
|
return ReqStatus.Error
|
||||||
|
|
||||||
|
|||||||
@ -184,7 +184,7 @@ proc handleClose*(
|
|||||||
raise newException(WSInvalidUTF8,
|
raise newException(WSInvalidUTF8,
|
||||||
"Invalid UTF8 sequence detected in close reason")
|
"Invalid UTF8 sequence detected in close reason")
|
||||||
|
|
||||||
trace "Handling close message", code, reason
|
trace "Handling close message", code = $code, reason
|
||||||
if not isNil(ws.onClose):
|
if not isNil(ws.onClose):
|
||||||
try:
|
try:
|
||||||
(code, reason) = ws.onClose(code, reason)
|
(code, reason) = ws.onClose(code, reason)
|
||||||
@ -197,7 +197,7 @@ proc handleClose*(
|
|||||||
# don't respond to a terminated connection
|
# don't respond to a terminated connection
|
||||||
if ws.readyState != ReadyState.Closing:
|
if ws.readyState != ReadyState.Closing:
|
||||||
ws.readyState = ReadyState.Closing
|
ws.readyState = ReadyState.Closing
|
||||||
trace "Sending close", code, reason
|
trace "Sending close", code = $code, reason
|
||||||
await ws.send(prepareCloseBody(code, reason), Opcode.Close)
|
await ws.send(prepareCloseBody(code, reason), Opcode.Close)
|
||||||
|
|
||||||
ws.readyState = ReadyState.Closed
|
ws.readyState = ReadyState.Closed
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user