mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 20:30:23 +00:00
Get rid of a binary construct in cowboy_http_websocket
Thanks to @nivertech for pointing it out in ticket #61.
This commit is contained in:
parent
b79e9fbeb4
commit
986630d9ad
1 changed files with 4 additions and 4 deletions
|
@ -358,7 +358,7 @@ handler_call(State=#state{handler=Handler, opts=Opts}, Req, HandlerState,
|
|||
%% hixie-76 text frame.
|
||||
websocket_send({text, Payload}, #state{version=0},
|
||||
#http_req{socket=Socket, transport=Transport}) ->
|
||||
Transport:send(Socket, << 0, Payload/binary, 255 >>);
|
||||
Transport:send(Socket, [0, Payload, 255]);
|
||||
%% Ignore all unknown frame types for compatibility with hixie 76.
|
||||
websocket_send(_Any, #state{version=0}, _Req) ->
|
||||
ignore;
|
||||
|
@ -370,9 +370,9 @@ websocket_send({Type, Payload}, _State,
|
|||
ping -> 9;
|
||||
pong -> 10
|
||||
end,
|
||||
Len = hybi_payload_length(byte_size(Payload)),
|
||||
Transport:send(Socket, << 1:1, 0:3, Opcode:4,
|
||||
0:1, Len/bits, Payload/binary >>).
|
||||
Len = hybi_payload_length(iolist_size(Payload)),
|
||||
Transport:send(Socket, [<< 1:1, 0:3, Opcode:4, 0:1, Len/bits >>,
|
||||
Payload]).
|
||||
|
||||
-spec websocket_close(#state{}, #http_req{}, any(), {atom(), atom()}) -> ok.
|
||||
websocket_close(State=#state{version=0}, Req=#http_req{socket=Socket,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue