diff options
author | Magnus Klaar <[email protected]> | 2011-12-10 17:58:31 +0100 |
---|---|---|
committer | Magnus Klaar <[email protected]> | 2011-12-10 18:33:09 +0100 |
commit | b1bbd023c54def70cf748ff78c02b8b021e87c18 (patch) | |
tree | be8e72caed4208320a159444d2fd179cbc7157f7 /src/cowboy_http_websocket.erl | |
parent | 168405830d564ff87fac61bd990c17ab6a35dfa8 (diff) | |
download | cowboy-b1bbd023c54def70cf748ff78c02b8b021e87c18.tar.gz cowboy-b1bbd023c54def70cf748ff78c02b8b021e87c18.tar.bz2 cowboy-b1bbd023c54def70cf748ff78c02b8b021e87c18.zip |
update /bits in binary expressions to /binary
This is a workaround for an issue in the hipe compiler where
compilation of code matching on binaries using patterns of the
form Data = <<Char, _Ignore/bits>> fails because _Ignore is
expected to be used. Using /binary instead of /bits resolves
the issue.
We're applying this change to all binary expressions in cowboy_http
because all functions in this module process human readable text
formats which are always expected to be bytestrings.
Two uses of /bits has been changed to /binary in cowboy_http_websocket
in two clauses of a single function, websocket_data/4. This is safe
to change because the data is later passed to binary:match/2 which
will always fail with a badarg error if the input is a bitstring
instead of a bytestring.
Diffstat (limited to 'src/cowboy_http_websocket.erl')
-rw-r--r-- | src/cowboy_http_websocket.erl | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cowboy_http_websocket.erl b/src/cowboy_http_websocket.erl index 7013d7f..20060e6 100644 --- a/src/cowboy_http_websocket.erl +++ b/src/cowboy_http_websocket.erl @@ -244,11 +244,11 @@ websocket_data(State, Req, HandlerState, <<>>) -> handler_before_loop(State, Req, HandlerState, <<>>); %% hixie-76 close frame. websocket_data(State=#state{version=0}, Req, HandlerState, - << 255, 0, _Rest/bits >>) -> + << 255, 0, _Rest/binary >>) -> websocket_close(State, Req, HandlerState, {normal, closed}); %% hixie-76 data frame. We only support the frame type 0, same as the specs. websocket_data(State=#state{version=0, eop=EOP}, Req, HandlerState, - Data = << 0, _/bits >>) -> + Data = << 0, _/binary >>) -> case binary:match(Data, EOP) of {Pos, 1} -> Pos2 = Pos - 1, |