-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set ibrowse version to point to the latest stable, add logs dir.
- Loading branch information
1 parent
8c1a7c1
commit 8cc6d6b
Showing
7 changed files
with
72 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
{erl_opts, [debug_info]}. | ||
|
||
{deps, [ | ||
{ibrowse, ".*", {git, "https://github.com/cmullaparthi/ibrowse.git" }}, | ||
{cowboy, ".*", {git, "https://github.com/ninenines/cowboy.git", {branch, "1.1.x"}}}, | ||
{mochiweb, ".*", {git, "https://github.com/mochi/mochiweb.git" }}, | ||
{ibrowse, ".*", {git, "https://github.com/cmullaparthi/ibrowse.git", {tag, "v4.4.0"} }}, | ||
%% {cowboy, ".*", {git, "https://github.com/ninenines/cowboy.git", {tag, "1.1.2"}}}, | ||
{cowboy, ".*", {git, "https://github.com/ninenines/cowboy.git", {tag, "2.2.2"}}}, | ||
{mochiweb, ".*", {git, "https://github.com/mochi/mochiweb.git" }}, | ||
{erlsom, ".*", {git, "https://github.com/willemdj/erlsom.git", {branch, "v1_4"}}} | ||
]}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,70 @@ | ||
-module(test_cowboy_middle_protocol). | ||
|
||
-export([start/1]). | ||
-export([start/2]). | ||
-export([stop/0]). | ||
-export([init/3, init/2]). | ||
-export([on_request/1]). | ||
-export([upgrade/4, upgrade/6]). | ||
-export([execute/2]). | ||
-export([upgrade/4]). | ||
|
||
start(Module) -> | ||
start(Module, []). | ||
|
||
start(Module, Options) -> | ||
|
||
Port = proplists:get_value(port, Options, 8080), | ||
Acceptors = proplists:get_value(nr_acceptors, Options, 100), | ||
{ok, _} = application:ensure_all_started(cowboy), | ||
Dispatch = cowboy_router:compile([ | ||
{'_', [{'_', ?MODULE, {Module, Options}}]}]), | ||
{ok, _} = cowboy:start_http(http, Acceptors, [{port, Port}], | ||
[ {env, [{dispatch, Dispatch}]}, | ||
{onrequest, fun ?MODULE:on_request/1} | ||
]). | ||
|
||
case proplists:get_value(cowboy_version, Options) of | ||
soap_server_cowboy_1 -> | ||
cowboy:start_http(http, 10, [{port, Port}], | ||
[ {env, [{dispatch, Dispatch}]}, | ||
{onrequest, fun ?MODULE:on_request/1} | ||
]); | ||
soap_server_cowboy_2 -> | ||
cowboy:start_clear(http, [{port, Port}], | ||
#{env => #{dispatch => Dispatch}, | ||
middlewares => [ cowboy_router | ||
, ?MODULE | ||
, cowboy_handler | ||
] | ||
} | ||
) | ||
end. | ||
|
||
stop() -> | ||
cowboy:stop_listener(http), | ||
application:stop(cowboy), | ||
application:stop(cowboy), | ||
application:stop(ranch). | ||
|
||
on_request(Req0) -> | ||
{ok, Body, Req1} = cowboy_req:body(Req0), | ||
cowboy_req:set_meta(body, Body, Req1). | ||
|
||
|
||
execute(Req, Env) -> | ||
{ok, Body, Req1} = cowboy_req:read_body(Req), | ||
{ok, Req1, maps:put(req_body, Body, Env)}. | ||
|
||
%% cowboy 1 callback | ||
init(_, _Req, {_Module, Options}) -> | ||
%% The module 'soap_cowboy_protocol' will be called | ||
%% for each request, with Module (= the handler module) and | ||
%% the options as parameter. | ||
%% for each request, with Module (= the handler module) and | ||
%% the options as parameter. | ||
soap_server_cowboy_1 = proplists:get_value(cowboy_version, Options), | ||
{upgrade, protocol, ?MODULE}. | ||
|
||
%% cowboy 1 callback | ||
upgrade(Cowboy_req, Env, Soap_handler, {Handler, Options}) -> | ||
Options2 = proplists:delete(cowboy_version, Options), | ||
{Message, Cowboy_req2} = cowboy_req:meta(body, Cowboy_req), | ||
|
||
soap_cowboy_1_protocol:upgrade( | ||
Cowboy_req2, Env, Soap_handler, {Handler, Options2}, Message). | ||
|
||
%% cowboy 2 callback | ||
init(Req, {Module, Options}) -> | ||
soap_server_cowboy_2 = proplists:get_value(cowboy_version, Options), | ||
{?MODULE, Req, {Module, Options}}. | ||
|
||
%% cowboy 2 callback | ||
upgrade(Cowboy_req, Env, Soap_handler, {Handler, Options}, Timeout, Hibernate) -> | ||
Options2 = proplists:delete(cowboy_version, Options), | ||
{Message, Cowboy_req2} = cowboy_req:meta(body, Cowboy_req), | ||
|
||
soap_cowboy_2_protocol:upgrade( | ||
Cowboy_req2, Env, Soap_handler, {Handler, Options2}, Timeout, Hibernate, Message). | ||
upgrade(Cowboy_req, Env, Soap_handler, {Handler, Options}) -> | ||
case proplists:get_value(cowboy_version, Options) of | ||
soap_server_cowboy_1 -> | ||
Options2 = proplists:delete(cowboy_version, Options), | ||
{Message, Cowboy_req2} = cowboy_req:meta(body, Cowboy_req), | ||
soap_cowboy_1_protocol:upgrade(Cowboy_req2, Env, Soap_handler, {Handler, Options2}, Message); | ||
soap_server_cowboy_2 -> | ||
Options2 = proplists:delete(cowboy_version, Options), | ||
Message = maps:get(req_body, Env), | ||
soap_cowboy_2_protocol:upgrade(Cowboy_req, Env, Soap_handler, {Handler, Options2}, Message) | ||
end. |