import json_ser and use ord
This commit is contained in:
parent
7e668c4c85
commit
78f2af5bac
|
@ -15,6 +15,10 @@ import pkg/[
|
|||
chronicles,
|
||||
httputils]
|
||||
|
||||
#required to log addresses in chronicle's json mode
|
||||
import json_serialization/std/net
|
||||
|
||||
|
||||
import ./common
|
||||
|
||||
type
|
||||
|
@ -38,13 +42,13 @@ proc validateRequest(
|
|||
##
|
||||
|
||||
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)
|
||||
return ReqStatus.Error
|
||||
|
||||
var hlen = header.contentLength()
|
||||
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)
|
||||
return ReqStatus.Error
|
||||
|
||||
|
|
|
@ -184,7 +184,7 @@ proc handleClose*(
|
|||
raise newException(WSInvalidUTF8,
|
||||
"Invalid UTF8 sequence detected in close reason")
|
||||
|
||||
trace "Handling close message", code = $code, reason
|
||||
trace "Handling close message", code = ord(code), reason
|
||||
if not isNil(ws.onClose):
|
||||
try:
|
||||
(code, reason) = ws.onClose(code, reason)
|
||||
|
@ -197,7 +197,7 @@ proc handleClose*(
|
|||
# don't respond to a terminated connection
|
||||
if ws.readyState != ReadyState.Closing:
|
||||
ws.readyState = ReadyState.Closing
|
||||
trace "Sending close", code = $code, reason
|
||||
trace "Sending close", code = ord(code), reason
|
||||
await ws.send(prepareCloseBody(code, reason), Opcode.Close)
|
||||
|
||||
ws.readyState = ReadyState.Closed
|
||||
|
|
Loading…
Reference in New Issue