2019-10-05 17:32:50 +02:00
|
|
|
%% This module disables UTF-8 validation.
|
|
|
|
|
|
|
|
-module(ws_dont_validate_utf8_h).
|
|
|
|
-behavior(cowboy_websocket).
|
|
|
|
|
|
|
|
-export([init/2]).
|
|
|
|
-export([websocket_handle/2]).
|
|
|
|
-export([websocket_info/2]).
|
|
|
|
|
|
|
|
init(Req, State) ->
|
|
|
|
{cowboy_websocket, Req, State, #{
|
|
|
|
validate_utf8 => false
|
|
|
|
}}.
|
|
|
|
|
|
|
|
websocket_handle({text, Data}, State) ->
|
2019-10-06 16:51:27 +02:00
|
|
|
{[{text, Data}], State};
|
2019-10-05 17:32:50 +02:00
|
|
|
websocket_handle({binary, Data}, State) ->
|
2019-10-06 16:51:27 +02:00
|
|
|
{[{binary, Data}], State};
|
2019-10-05 17:32:50 +02:00
|
|
|
websocket_handle(_, State) ->
|
2019-10-06 16:51:27 +02:00
|
|
|
{[], State}.
|
2019-10-05 17:32:50 +02:00
|
|
|
|
|
|
|
websocket_info(_, State) ->
|
2019-10-06 16:51:27 +02:00
|
|
|
{[], State}.
|