Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/soap_cowboy_2_protocol.erl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
-module(soap_cowboy_2_protocol).
%%-behaviour(cowboy_sub_protocol).

-export([upgrade/6]).
-export([upgrade/4]).
-export([enrich_req/2]).
-export([respond/4]).

Expand All @@ -45,10 +45,10 @@
%% From the Cowboy documentation:
%% This callback is expected to behave like a middleware and to return an
%% updated req object and environment.
-spec upgrade(Cowboy_req::cowboy_req(), Env::cowboy_env(),
Soap_handler::module(), {Implementation_handler::module(), Options::any()},
Timeout::any(), Hibernate::any()) -> {ok, cowboy_req(), cowboy_env()}.
upgrade(Cowboy_req, Env, Soap_handler, {Handler, Options}, _, _) ->
-spec upgrade(Cowboy_req::cowboy_req(), Env::cowboy_env(), Soap_handler::module(),
{Implementation_handler::module(), Options::any()}) ->
{ok, cowboy_req(), cowboy_env()}.
upgrade(Cowboy_req, Env, Soap_handler, {Handler, Options}) ->
soap_cowboy_protocol:upgrade(Cowboy_req, Env, Soap_handler,
{Handler, Options}, cowboy_2, ?MODULE).

Expand Down
5 changes: 4 additions & 1 deletion src/soap_cowboy_protocol.erl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ check_conformance(Soap_req, Cowboy_req, Cowboy_state, Version_module) ->

handle_xml(Soap_req, Cowboy_state, Version_module) ->
Cowboy_req = soap_req:server_req(Soap_req),
{ok, Message, Cowboy_req2} = cowboy_req:body(Cowboy_req),
{ok, Message, Cowboy_req2} = case soap_req:server(Soap_req) of
cowboy_1 -> cowboy_req:body(Cowboy_req);
cowboy_2 -> cowboy_req:read_body(Cowboy_req)
end,
Soap_req2 = soap_req:set_server_req(Soap_req, Cowboy_req2),
Soap_req3 = soap_req:set_http_body(Soap_req2, Message),
Content_type = soap_req:content_type(Soap_req3),
Expand Down
12 changes: 4 additions & 8 deletions src/soap_server_cowboy_2.erl
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,10 @@ start(Module) ->
start(Module, Options) ->
Port = proplists:get_value(port, Options, 8080),
Acceptors = proplists:get_value(nr_acceptors, Options, 100),
ok = application:ensure_started(crypto),
ok = application:ensure_started(ranch),
ok = application:ensure_started(cowlib),
ok = application:ensure_started(cowboy),
Dispatch = cowboy_router:compile([
{'_', [{'_', ?MODULE, {Module, Options}}]}]),
{ok, _} = cowboy:start_http(http, Acceptors, [{port, Port}], [
{env, [{dispatch, Dispatch}]}]).
Opts = [{port, Port}, {num_acceptors, Acceptors}],
{ok, _} = application:ensure_all_started(cowboy),
Dispatch = cowboy_router:compile([{'_', [{'_', ?MODULE, {Module, Options}}]}]),
{ok, _} = cowboy:start_clear(http, Opts, #{env => #{dispatch => Dispatch}}).

stop() ->
cowboy:stop_listener(http),
Expand Down