Remove some code cuplication

This commit is contained in:
Maciej Szlosarczyk 2019-07-30 13:46:55 +03:00
parent 0e46f52630
commit a73f7428fc
No known key found for this signature in database
GPG key ID: 41D62D42D3B0D765
4 changed files with 10 additions and 16 deletions

View file

@ -8,8 +8,13 @@
epp_verb % Epp verb that is targeted, plus 'error' epp_verb % Epp verb that is targeted, plus 'error'
}). }).
-type epp_request() :: #epp_request{}. -record(valid_frame, {command, cl_trid, raw_frame}).
-record(invalid_frame, {code, cl_trid, message}).
-record(state, {socket, session_id, headers}).
-type epp_request() :: #epp_request{}.
-define(XMLErrorCode, <<"2001">>). -define(XMLErrorCode, <<"2001">>).

View file

@ -84,8 +84,8 @@ request_from_map(#{command := Command,
%% Get hackney options %% Get hackney options
hackney_options(Cookies) -> hackney_options(Cookies) ->
case application:get_env(epp_proxy, insecure) of case application:get_env(epp_proxy, insecure) of
false -> [{cookies, Cookies}, insecure]; false -> [{cookie, Cookies}, insecure];
_ -> [{cookies, Cookies}] _ -> [{cookie, Cookies}]
end. end.
%% Return form data or an empty list. %% Return form data or an empty list.

View file

@ -12,12 +12,6 @@
-export([code_change/3]). -export([code_change/3]).
-record(valid_frame, {command, cl_trid, raw_frame}).
-record(invalid_frame, {code, cl_trid, message}).
-record(state, {socket, session_id, headers}).
%% Initialize process %% Initialize process
%% Assign an unique session id that will be passed on to http server as a cookie %% Assign an unique session id that will be passed on to http server as a cookie
init(Socket) -> init(Socket) ->

View file

@ -12,12 +12,6 @@
-export([code_change/3]). -export([code_change/3]).
-record(valid_frame, {command, cl_trid, raw_frame}).
-record(invalid_frame, {code, cl_trid, message}).
-record(state, {socket, session_id, headers}).
%% Initialize process %% Initialize process
%% Assign an unique session id that will be passed on to http server as a cookie %% Assign an unique session id that will be passed on to http server as a cookie
init(Socket) -> init(Socket) ->
@ -171,7 +165,8 @@ log_on_invalid_handshake(Ip, Error) ->
log_opened_connection(Ip) -> log_opened_connection(Ip) ->
ReadableIp = epp_util:readable_ip(Ip), ReadableIp = epp_util:readable_ip(Ip),
lager:info("New client connection. IP: ~s, Process: ~p.~n", lager:info("New client connection. IP: ~s, Process: "
"~p.~n",
[ReadableIp, self()]). [ReadableIp, self()]).
%% Extract state info from socket. Fail if you must. %% Extract state info from socket. Fail if you must.