| 1 |
%% This module disables UTF-8 validation. |
| 2 |
|
| 3 |
-module(ws_dont_validate_utf8_h). |
| 4 |
-behavior(cowboy_websocket). |
| 5 |
|
| 6 |
-export([init/2]). |
| 7 |
-export([websocket_handle/2]). |
| 8 |
-export([websocket_info/2]). |
| 9 |
|
| 10 |
init(Req, State) -> |
| 11 |
{cowboy_websocket, Req, State, #{ |
| 12 |
validate_utf8 => false |
| 13 |
}}. |
| 14 |
|
| 15 |
websocket_handle({text, Data}, State) -> |
| 16 |
{[{text, Data}], State}; |
| 17 |
websocket_handle({binary, Data}, State) -> |
| 18 |
{[{binary, Data}], State}; |
| 19 |
websocket_handle(_, State) -> |
| 20 |
{[], State}. |
| 21 |
|
| 22 |
websocket_info(_, State) -> |
| 23 |
{[], State}. |