fix websocket close wrapper
This commit is contained in:
parent
5e45349fff
commit
2fb7d018d5
1 changed files with 6 additions and 3 deletions
|
@ -43,16 +43,19 @@ module Kemal
|
|||
context.response.status_code = 500
|
||||
|
||||
if error.is_a?(WebsocketError)
|
||||
code = error.code.to_i16
|
||||
code = error.code.to_i32
|
||||
message = error.status_message
|
||||
else
|
||||
code = 1011_i16
|
||||
code = 1011_i32
|
||||
message = "Exception"
|
||||
end
|
||||
|
||||
raw = uninitialized UInt8[2]
|
||||
IO::ByteFormat::BigEndian.encode(code, raw.to_slice)
|
||||
socket.not_nil!.close(String.new(raw.to_slice) + message)
|
||||
socket.not_nil!.close(
|
||||
HTTP::WebSocket::CloseCode.new(code),
|
||||
message: String.new(raw.to_slice) + message
|
||||
)
|
||||
|
||||
raise error unless error.is_a?(WebsocketError)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue