From 9c662615ace7e8b9c075e8a6a1752d849276b13d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Fri, 21 Mar 2014 10:49:44 +0100 Subject: Add a debug function to send raw data --- src/gun.erl | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/gun.erl b/src/gun.erl index 978e550..16aa6a4 100644 --- a/src/gun.erl +++ b/src/gun.erl @@ -49,6 +49,9 @@ -export([ws_upgrade/3]). -export([ws_send/2]). +%% Debug. +-export([dbg_send_raw/2]). + %% Internals. -export([start_link/4]). -export([init/5]). @@ -226,6 +229,13 @@ ws_send(ServerPid, Frames) -> _ = ServerPid ! {ws_send, self(), Frames}, ok. +%% Debug. + +-spec dbg_send_raw(pid(), iodata()) -> ok. +dbg_send_raw(ServerPid, Data) -> + _ = ServerPid ! {dbg_send_raw, self(), Data}, + ok. + %% Internals. start_link(Owner, Host, Port, Opts) -> @@ -358,6 +368,9 @@ loop(State=#state{parent=Parent, owner=Owner, host=Host, {system, From, Request} -> sys:handle_system_msg(Request, From, Parent, ?MODULE, [], {loop, State}); + {dbg_send_raw, Owner, Data} -> + Transport:send(Socket, Data), + loop(State); Any when is_tuple(Any), is_pid(element(2, Any)) -> element(2, Any) ! {gun_error, self(), {notowner, "Operations are restricted to the owner of the connection."}}, -- cgit v1.2.3