Compare commits

...

2 commits

Author SHA1 Message Date
bba5bef505 don't prepend raw close code anymore
thanks to recent crystal changes adding support for close reasons we
don't need to encode things anymore.
2021-05-12 12:17:02 -03:00
faeaeb4fba FORK.md: add notes on upstreamability of my patches 2021-05-12 12:16:53 -03:00
2 changed files with 6 additions and 3 deletions

View file

@ -4,9 +4,14 @@ This is the outline of the changes done in this fork, compared to Kemal upstream
- Default HEAD request removed has been removed. If you wish to provide it, - Default HEAD request removed has been removed. If you wish to provide it,
you must give your own handler. you must give your own handler.
- Can not be upstreamed as it would be a breaking change that I did not
ask upstream about. This is a very specific issue to the web services I
write.
- Fix to prevent overwriting the `content-length` header value when set by the - Fix to prevent overwriting the `content-length` header value when set by the
request handler. request handler.
- Could be upstreamed, as it is a single line fix.
- Websockets can be closed via an exception, with support for reasons. - Websockets can be closed via an exception, with support for reasons.
- Can not be upstreamed. Same reasoning as the first change.
## Installation? ## Installation?

View file

@ -50,11 +50,9 @@ module Kemal
message = "Exception" message = "Exception"
end end
raw = uninitialized UInt8[2]
IO::ByteFormat::BigEndian.encode(code, raw.to_slice)
socket.not_nil!.close( socket.not_nil!.close(
HTTP::WebSocket::CloseCode.new(code), HTTP::WebSocket::CloseCode.new(code),
message: String.new(raw.to_slice) + message message: message
) )
raise error unless error.is_a?(WebsocketError) raise error unless error.is_a?(WebsocketError)