From 95a41e6c941c12f34592f3fed911fd405e787b24 Mon Sep 17 00:00:00 2001 From: Rob Ashton Date: Thu, 9 Apr 2015 18:01:38 +0100 Subject: WS accepts iodata, so byte_size won't work unless we flatten --- src/cow_ws.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cow_ws.erl b/src/cow_ws.erl index c89c17a..c025b38 100644 --- a/src/cow_ws.erl +++ b/src/cow_ws.erl @@ -580,7 +580,7 @@ masked_frame({binary, Payload}, _) -> [<< 1:1, 0:3, 2:4, 1:1, Len/bits >>, MaskKeyBin, mask(iolist_to_binary(Payload), MaskKey, <<>>)]. payload_length(Payload) -> - case byte_size(Payload) of + case iolist_size(Payload) of N when N =< 125 -> << N:7 >>; N when N =< 16#ffff -> << 126:7, N:16 >>; N when N =< 16#7fffffffffffffff -> << 127:7, N:64 >> -- cgit v1.2.3