Last active
December 23, 2015 09:19
-
-
Save okeuday/6614126 to your computer and use it in GitHub Desktop.
cowboy patch for barrel usage from Aug 17 11:40, changes from https://github.com/refuge/cowboy
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
diff --git a/Makefile b/Makefile | |
index 79c2b6c..28cb135 100644 | |
--- a/Makefile | |
+++ b/Makefile | |
@@ -10,9 +10,9 @@ PLT_APPS = crypto public_key ssl | |
# Dependencies. | |
-DEPS = ranch | |
+DEPS = barrel | |
TEST_DEPS = ct_helper | |
-dep_ranch = https://github.com/extend/ranch.git 0.8.4 | |
+dep_barrel = https://github.com/benoitc/barrel.git master | |
dep_ct_helper = https://github.com/extend/ct_helper.git master | |
# Standard targets. | |
diff --git a/examples/basic_auth/rebar.config b/examples/basic_auth/rebar.config | |
index 6ad3062..454d4cd 100644 | |
--- a/examples/basic_auth/rebar.config | |
+++ b/examples/basic_auth/rebar.config | |
@@ -1,4 +1,4 @@ | |
{deps, [ | |
{cowboy, ".*", | |
- {git, "git://github.com/extend/cowboy.git", "master"}} | |
+ {git, "git://github.com/refuge/cowboy.git", {branch, "barrel"}}} | |
]}. | |
diff --git a/examples/basic_auth/src/basic_auth.erl b/examples/basic_auth/src/basic_auth.erl | |
index 9294c77..090b594 100644 | |
--- a/examples/basic_auth/src/basic_auth.erl | |
+++ b/examples/basic_auth/src/basic_auth.erl | |
@@ -9,6 +9,6 @@ | |
start() -> | |
ok = application:start(crypto), | |
- ok = application:start(ranch), | |
+ ok = application:start(barrel), | |
ok = application:start(cowboy), | |
ok = application:start(basic_auth). | |
diff --git a/examples/chunked_hello_world/rebar.config b/examples/chunked_hello_world/rebar.config | |
index 6ad3062..834455d 100644 | |
--- a/examples/chunked_hello_world/rebar.config | |
+++ b/examples/chunked_hello_world/rebar.config | |
@@ -1,4 +1,4 @@ | |
{deps, [ | |
{cowboy, ".*", | |
- {git, "git://github.com/extend/cowboy.git", "master"}} | |
+ {git, "git://github.com/refuge/cowboy.git", "barrel"}} | |
]}. | |
diff --git a/examples/chunked_hello_world/src/chunked_hello_world.erl b/examples/chunked_hello_world/src/chunked_hello_world.erl | |
index 78c771f..2ed480a 100644 | |
--- a/examples/chunked_hello_world/src/chunked_hello_world.erl | |
+++ b/examples/chunked_hello_world/src/chunked_hello_world.erl | |
@@ -9,6 +9,6 @@ | |
start() -> | |
ok = application:start(crypto), | |
- ok = application:start(ranch), | |
+ ok = application:start(barre), | |
ok = application:start(cowboy), | |
ok = application:start(chunked_hello_world). | |
diff --git a/examples/compress_response/rebar.config b/examples/compress_response/rebar.config | |
index 6ad3062..834455d 100644 | |
--- a/examples/compress_response/rebar.config | |
+++ b/examples/compress_response/rebar.config | |
@@ -1,4 +1,4 @@ | |
{deps, [ | |
{cowboy, ".*", | |
- {git, "git://github.com/extend/cowboy.git", "master"}} | |
+ {git, "git://github.com/refuge/cowboy.git", "barrel"}} | |
]}. | |
diff --git a/examples/compress_response/src/compress_response.erl b/examples/compress_response/src/compress_response.erl | |
index ac2636c..be9cfc5 100644 | |
--- a/examples/compress_response/src/compress_response.erl | |
+++ b/examples/compress_response/src/compress_response.erl | |
@@ -9,6 +9,6 @@ | |
start() -> | |
ok = application:start(crypto), | |
- ok = application:start(ranch), | |
+ ok = application:start(barrel), | |
ok = application:start(cowboy), | |
ok = application:start(compress_response). | |
diff --git a/examples/cookie/rebar.config b/examples/cookie/rebar.config | |
index d1fecef..6ff298b 100644 | |
--- a/examples/cookie/rebar.config | |
+++ b/examples/cookie/rebar.config | |
@@ -1,6 +1,6 @@ | |
{deps, [ | |
{cowboy, ".*", | |
- {git, "git://github.com/extend/cowboy.git", "master"}}, | |
+ {git, "git://github.com/refuge/cowboy.git", "barrel"}}, | |
{erlydtl, ".*", | |
{git, "https://github.com/evanmiller/erlydtl.git", "master"}} | |
]}. | |
diff --git a/examples/cookie/src/cookie.erl b/examples/cookie/src/cookie.erl | |
index 455fcb0..a0b454d 100644 | |
--- a/examples/cookie/src/cookie.erl | |
+++ b/examples/cookie/src/cookie.erl | |
@@ -9,6 +9,6 @@ | |
start() -> | |
ok = application:start(crypto), | |
- ok = application:start(ranch), | |
+ ok = application:start(barrel), | |
ok = application:start(cowboy), | |
ok = application:start(cookie). | |
diff --git a/examples/echo_get/rebar.config b/examples/echo_get/rebar.config | |
index 6ad3062..834455d 100644 | |
--- a/examples/echo_get/rebar.config | |
+++ b/examples/echo_get/rebar.config | |
@@ -1,4 +1,4 @@ | |
{deps, [ | |
{cowboy, ".*", | |
- {git, "git://github.com/extend/cowboy.git", "master"}} | |
+ {git, "git://github.com/refuge/cowboy.git", "barrel"}} | |
]}. | |
diff --git a/examples/echo_get/src/echo_get.erl b/examples/echo_get/src/echo_get.erl | |
index 6ffff41..41a489d 100644 | |
--- a/examples/echo_get/src/echo_get.erl | |
+++ b/examples/echo_get/src/echo_get.erl | |
@@ -9,6 +9,6 @@ | |
start() -> | |
ok = application:start(crypto), | |
- ok = application:start(ranch), | |
+ ok = application:start(barrel), | |
ok = application:start(cowboy), | |
ok = application:start(echo_get). | |
diff --git a/examples/echo_post/rebar.config b/examples/echo_post/rebar.config | |
index 6ad3062..834455d 100644 | |
--- a/examples/echo_post/rebar.config | |
+++ b/examples/echo_post/rebar.config | |
@@ -1,4 +1,4 @@ | |
{deps, [ | |
{cowboy, ".*", | |
- {git, "git://github.com/extend/cowboy.git", "master"}} | |
+ {git, "git://github.com/refuge/cowboy.git", "barrel"}} | |
]}. | |
diff --git a/examples/echo_post/src/echo_post.erl b/examples/echo_post/src/echo_post.erl | |
index c7c8ce1..2983fd6 100644 | |
--- a/examples/echo_post/src/echo_post.erl | |
+++ b/examples/echo_post/src/echo_post.erl | |
@@ -9,6 +9,6 @@ | |
start() -> | |
ok = application:start(crypto), | |
- ok = application:start(ranch), | |
+ ok = application:start(barrel), | |
ok = application:start(cowboy), | |
ok = application:start(echo_post). | |
diff --git a/examples/elixir_hello_world/mix.exs b/examples/elixir_hello_world/mix.exs | |
index 9055175..4588263 100644 | |
--- a/examples/elixir_hello_world/mix.exs | |
+++ b/examples/elixir_hello_world/mix.exs | |
@@ -14,7 +14,7 @@ defmodule ElixirHelloWorld.Mixfile do | |
end | |
defp deps do | |
- [ {:ranch, github: "extend/ranch", tag: "0.8.4"}, | |
- {:cowboy, github: "extend/cowboy"} ] | |
+ [ {:barrel, github: "benoitc/barrel", tag: "2.1"}, | |
+ {:cowboy, github: "refuge/cowboy", branch, "barrel"} ] | |
end | |
end | |
diff --git a/examples/error_hook/rebar.config b/examples/error_hook/rebar.config | |
index 6ad3062..454d4cd 100644 | |
--- a/examples/error_hook/rebar.config | |
+++ b/examples/error_hook/rebar.config | |
@@ -1,4 +1,4 @@ | |
{deps, [ | |
{cowboy, ".*", | |
- {git, "git://github.com/extend/cowboy.git", "master"}} | |
+ {git, "git://github.com/refuge/cowboy.git", {branch, "barrel"}}} | |
]}. | |
diff --git a/examples/error_hook/src/error_hook.erl b/examples/error_hook/src/error_hook.erl | |
index 3543590..514c5fd 100644 | |
--- a/examples/error_hook/src/error_hook.erl | |
+++ b/examples/error_hook/src/error_hook.erl | |
@@ -9,6 +9,6 @@ | |
start() -> | |
ok = application:start(crypto), | |
- ok = application:start(ranch), | |
+ ok = application:start(barrel), | |
ok = application:start(cowboy), | |
ok = application:start(error_hook). | |
diff --git a/examples/eventsource/rebar.config b/examples/eventsource/rebar.config | |
index eb6f194..0d55f40 100644 | |
--- a/examples/eventsource/rebar.config | |
+++ b/examples/eventsource/rebar.config | |
@@ -1,6 +1,6 @@ | |
{deps, [ | |
{cowboy, ".*", | |
- {git, "git://github.com/extend/cowboy.git", "master"}}, | |
+ {git, "git://github.com/refuge/cowboy.git", "barrel"}}, | |
{mimetypes, ".*", | |
{git, "git://github.com/spawngrid/mimetypes.git", "master"}} | |
]}. | |
diff --git a/examples/eventsource/src/eventsource.erl b/examples/eventsource/src/eventsource.erl | |
index 6505e62..3436e8b 100644 | |
--- a/examples/eventsource/src/eventsource.erl | |
+++ b/examples/eventsource/src/eventsource.erl | |
@@ -9,6 +9,6 @@ | |
start() -> | |
ok = application:start(crypto), | |
- ok = application:start(ranch), | |
+ ok = application:start(barre), | |
ok = application:start(cowboy), | |
ok = application:start(eventsource). | |
diff --git a/examples/hello_world/rebar.config b/examples/hello_world/rebar.config | |
index 6ad3062..834455d 100644 | |
--- a/examples/hello_world/rebar.config | |
+++ b/examples/hello_world/rebar.config | |
@@ -1,4 +1,4 @@ | |
{deps, [ | |
{cowboy, ".*", | |
- {git, "git://github.com/extend/cowboy.git", "master"}} | |
+ {git, "git://github.com/refuge/cowboy.git", "barrel"}} | |
]}. | |
diff --git a/examples/hello_world/src/hello_world.erl b/examples/hello_world/src/hello_world.erl | |
index d62ff4b..2e706c8 100644 | |
--- a/examples/hello_world/src/hello_world.erl | |
+++ b/examples/hello_world/src/hello_world.erl | |
@@ -9,6 +9,6 @@ | |
start() -> | |
ok = application:start(crypto), | |
- ok = application:start(ranch), | |
+ ok = application:start(barrel), | |
ok = application:start(cowboy), | |
ok = application:start(hello_world). | |
diff --git a/examples/markdown_middleware/rebar.config b/examples/markdown_middleware/rebar.config | |
index bd34059..78686d5 100644 | |
--- a/examples/markdown_middleware/rebar.config | |
+++ b/examples/markdown_middleware/rebar.config | |
@@ -1,6 +1,6 @@ | |
{deps, [ | |
{cowboy, ".*", | |
- {git, "git://github.com/extend/cowboy.git", "master"}}, | |
+ {git, "git://github.com/refuge/cowboy.git", "barrel"}}, | |
{mimetypes, ".*", | |
{git, "git://github.com/spawngrid/mimetypes.git", "master"}}, | |
{erlmarkdown, ".*", | |
diff --git a/examples/rest_hello_world/rebar.config b/examples/rest_hello_world/rebar.config | |
index 6ad3062..834455d 100644 | |
--- a/examples/rest_hello_world/rebar.config | |
+++ b/examples/rest_hello_world/rebar.config | |
@@ -1,4 +1,4 @@ | |
{deps, [ | |
{cowboy, ".*", | |
- {git, "git://github.com/extend/cowboy.git", "master"}} | |
+ {git, "git://github.com/refuge/cowboy.git", "barrel"}} | |
]}. | |
diff --git a/examples/rest_hello_world/src/rest_hello_world.erl b/examples/rest_hello_world/src/rest_hello_world.erl | |
index e2b7463..67acec9 100644 | |
--- a/examples/rest_hello_world/src/rest_hello_world.erl | |
+++ b/examples/rest_hello_world/src/rest_hello_world.erl | |
@@ -9,6 +9,6 @@ | |
start() -> | |
ok = application:start(crypto), | |
- ok = application:start(ranch), | |
+ ok = application:start(barrel), | |
ok = application:start(cowboy), | |
ok = application:start(rest_hello_world). | |
diff --git a/examples/rest_pastebin/rebar.config b/examples/rest_pastebin/rebar.config | |
index 6ad3062..834455d 100644 | |
--- a/examples/rest_pastebin/rebar.config | |
+++ b/examples/rest_pastebin/rebar.config | |
@@ -1,4 +1,4 @@ | |
{deps, [ | |
{cowboy, ".*", | |
- {git, "git://github.com/extend/cowboy.git", "master"}} | |
+ {git, "git://github.com/refuge/cowboy.git", "barrel"}} | |
]}. | |
diff --git a/examples/rest_pastebin/src/rest_pastebin.erl b/examples/rest_pastebin/src/rest_pastebin.erl | |
index cf03a71..7dc152d 100644 | |
--- a/examples/rest_pastebin/src/rest_pastebin.erl | |
+++ b/examples/rest_pastebin/src/rest_pastebin.erl | |
@@ -9,6 +9,6 @@ | |
start() -> | |
ok = application:start(crypto), | |
- ok = application:start(ranch), | |
+ ok = application:start(barrel), | |
ok = application:start(cowboy), | |
ok = application:start(rest_pastebin). | |
diff --git a/examples/rest_stream_response/rebar.config b/examples/rest_stream_response/rebar.config | |
index 6ad3062..834455d 100644 | |
--- a/examples/rest_stream_response/rebar.config | |
+++ b/examples/rest_stream_response/rebar.config | |
@@ -1,4 +1,4 @@ | |
{deps, [ | |
{cowboy, ".*", | |
- {git, "git://github.com/extend/cowboy.git", "master"}} | |
+ {git, "git://github.com/refuge/cowboy.git", "barrel"}} | |
]}. | |
diff --git a/examples/rest_stream_response/src/rest_stream_response.erl b/examples/rest_stream_response/src/rest_stream_response.erl | |
index ef24309..a173edf 100644 | |
--- a/examples/rest_stream_response/src/rest_stream_response.erl | |
+++ b/examples/rest_stream_response/src/rest_stream_response.erl | |
@@ -9,6 +9,6 @@ | |
start() -> | |
ok = application:start(crypto), | |
- ok = application:start(ranch), | |
+ ok = application:start(barrel), | |
ok = application:start(cowboy), | |
ok = application:start(rest_stream_response). | |
diff --git a/examples/ssl_hello_world/rebar.config b/examples/ssl_hello_world/rebar.config | |
index 6ad3062..834455d 100644 | |
--- a/examples/ssl_hello_world/rebar.config | |
+++ b/examples/ssl_hello_world/rebar.config | |
@@ -1,4 +1,4 @@ | |
{deps, [ | |
{cowboy, ".*", | |
- {git, "git://github.com/extend/cowboy.git", "master"}} | |
+ {git, "git://github.com/refuge/cowboy.git", "barrel"}} | |
]}. | |
diff --git a/examples/ssl_hello_world/src/ssl_hello_world.erl b/examples/ssl_hello_world/src/ssl_hello_world.erl | |
index 1413b7b..1e9b9a6 100644 | |
--- a/examples/ssl_hello_world/src/ssl_hello_world.erl | |
+++ b/examples/ssl_hello_world/src/ssl_hello_world.erl | |
@@ -9,6 +9,6 @@ | |
start() -> | |
ok = application:start(crypto), | |
- ok = application:start(ranch), | |
+ ok = application:start(refuge), | |
ok = application:start(cowboy), | |
ok = application:start(ssl_hello_world). | |
diff --git a/examples/static_world/rebar.config b/examples/static_world/rebar.config | |
index eb6f194..0d55f40 100644 | |
--- a/examples/static_world/rebar.config | |
+++ b/examples/static_world/rebar.config | |
@@ -1,6 +1,6 @@ | |
{deps, [ | |
{cowboy, ".*", | |
- {git, "git://github.com/extend/cowboy.git", "master"}}, | |
+ {git, "git://github.com/refuge/cowboy.git", "barrel"}}, | |
{mimetypes, ".*", | |
{git, "git://github.com/spawngrid/mimetypes.git", "master"}} | |
]}. | |
diff --git a/examples/static_world/src/static_world.erl b/examples/static_world/src/static_world.erl | |
index 6425a99..afa93d1 100644 | |
--- a/examples/static_world/src/static_world.erl | |
+++ b/examples/static_world/src/static_world.erl | |
@@ -9,6 +9,6 @@ | |
start() -> | |
ok = application:start(crypto), | |
- ok = application:start(ranch), | |
+ ok = application:start(barrel), | |
ok = application:start(cowboy), | |
ok = application:start(static_world). | |
diff --git a/examples/web_server/rebar.config b/examples/web_server/rebar.config | |
index f9cbdef..b76da77 100644 | |
--- a/examples/web_server/rebar.config | |
+++ b/examples/web_server/rebar.config | |
@@ -1,6 +1,6 @@ | |
{deps, [ | |
{cowboy, ".*", | |
- {git, "git://github.com/extend/cowboy.git", "master"}}, | |
+ {git, "git://github.com/refuge/cowboy.git", "barrel"}}, | |
{mimetypes, ".*", | |
{git, "git://github.com/spawngrid/mimetypes.git", "master"}}, | |
{jsx, ".*", | |
diff --git a/examples/web_server/src/web_server.erl b/examples/web_server/src/web_server.erl | |
index ae75c3a..c6fa77d 100644 | |
--- a/examples/web_server/src/web_server.erl | |
+++ b/examples/web_server/src/web_server.erl | |
@@ -9,6 +9,6 @@ | |
start() -> | |
ok = application:start(crypto), | |
- ok = application:start(ranch), | |
+ ok = application:start(barrel), | |
ok = application:start(cowboy), | |
ok = application:start(web_server). | |
diff --git a/examples/websocket/rebar.config b/examples/websocket/rebar.config | |
index eb6f194..0d55f40 100644 | |
--- a/examples/websocket/rebar.config | |
+++ b/examples/websocket/rebar.config | |
@@ -1,6 +1,6 @@ | |
{deps, [ | |
{cowboy, ".*", | |
- {git, "git://github.com/extend/cowboy.git", "master"}}, | |
+ {git, "git://github.com/refuge/cowboy.git", "barrel"}}, | |
{mimetypes, ".*", | |
{git, "git://github.com/spawngrid/mimetypes.git", "master"}} | |
]}. | |
diff --git a/examples/websocket/src/websocket.erl b/examples/websocket/src/websocket.erl | |
index da2a91c..c0a64fb 100644 | |
--- a/examples/websocket/src/websocket.erl | |
+++ b/examples/websocket/src/websocket.erl | |
@@ -7,6 +7,6 @@ | |
start() -> | |
ok = application:start(crypto), | |
- ok = application:start(ranch), | |
+ ok = application:start(barrel), | |
ok = application:start(cowboy), | |
ok = application:start(websocket). | |
diff --git a/rebar.config b/rebar.config | |
index 443949a..3c5c4b4 100644 | |
--- a/rebar.config | |
+++ b/rebar.config | |
@@ -1,3 +1,3 @@ | |
{deps, [ | |
- {ranch, ".*", {git, "git://github.com/extend/ranch.git", "0.8.4"}} | |
+ {barrel, ".*", {git, "git://github.com/benoitc/barrel.git", "master"}} | |
]}. | |
diff --git a/src/cowboy.app.src b/src/cowboy.app.src | |
index 0c4a5b1..10359aa 100644 | |
--- a/src/cowboy.app.src | |
+++ b/src/cowboy.app.src | |
@@ -20,7 +20,7 @@ | |
{applications, [ | |
kernel, | |
stdlib, | |
- ranch, | |
+ barrel, | |
crypto | |
]}, | |
{mod, {cowboy_app, []}}, | |
diff --git a/src/cowboy.erl b/src/cowboy.erl | |
index abc7911..0d1304e 100644 | |
--- a/src/cowboy.erl | |
+++ b/src/cowboy.erl | |
@@ -38,23 +38,23 @@ | |
-export_type([onresponse_fun/0]). | |
%% @doc Start an HTTP listener. | |
--spec start_http(ranch:ref(), non_neg_integer(), ranch_tcp:opts(), | |
+-spec start_http(barrel:ref(), non_neg_integer(), barrel_tcp:opts(), | |
cowboy_protocol:opts()) -> {ok, pid()} | {error, any()}. | |
start_http(Ref, NbAcceptors, TransOpts, ProtoOpts) | |
when is_integer(NbAcceptors), NbAcceptors > 0 -> | |
- ranch:start_listener(Ref, NbAcceptors, | |
- ranch_tcp, TransOpts, cowboy_protocol, ProtoOpts). | |
+ barrel:start_listener(Ref, NbAcceptors, | |
+ barrel_tcp, TransOpts, cowboy_protocol, ProtoOpts). | |
%% @doc Start an HTTPS listener. | |
--spec start_https(ranch:ref(), non_neg_integer(), ranch_ssl:opts(), | |
+-spec start_https(barrel:ref(), non_neg_integer(), barrel_ssl:opts(), | |
cowboy_protocol:opts()) -> {ok, pid()} | {error, any()}. | |
start_https(Ref, NbAcceptors, TransOpts, ProtoOpts) | |
when is_integer(NbAcceptors), NbAcceptors > 0 -> | |
- ranch:start_listener(Ref, NbAcceptors, | |
- ranch_ssl, TransOpts, cowboy_protocol, ProtoOpts). | |
+ barrel:start_listener(Ref, NbAcceptors, | |
+ barrel_ssl, TransOpts, cowboy_protocol, ProtoOpts). | |
%% @doc Start a SPDY listener. | |
--spec start_spdy(ranch:ref(), non_neg_integer(), ranch_ssl:opts(), | |
+-spec start_spdy(barrel:ref(), non_neg_integer(), barrel_ssl:opts(), | |
cowboy_spdy:opts()) -> {ok, pid()} | {error, any()}. | |
start_spdy(Ref, NbAcceptors, TransOpts, ProtoOpts) | |
when is_integer(NbAcceptors), NbAcceptors > 0 -> | |
@@ -63,23 +63,23 @@ start_spdy(Ref, NbAcceptors, TransOpts, ProtoOpts) | |
{next_protocols_advertised, | |
[<<"spdy/3">>, <<"http/1.1">>, <<"http/1.0">>]} | |
|TransOpts], | |
- ranch:start_listener(Ref, NbAcceptors, | |
- ranch_ssl, TransOpts2, cowboy_spdy, ProtoOpts). | |
+ barrel:start_listener(Ref, NbAcceptors, | |
+ barrel_ssl, TransOpts2, cowboy_spdy, ProtoOpts). | |
%% @doc Stop a listener. | |
--spec stop_listener(ranch:ref()) -> ok. | |
+-spec stop_listener(barrel:ref()) -> ok. | |
stop_listener(Ref) -> | |
- ranch:stop_listener(Ref). | |
+ barrel:stop_listener(Ref). | |
%% @doc Convenience function for setting an environment value. | |
%% | |
%% Allows you to update live an environment value used by middlewares. | |
%% This function is primarily intended to simplify updating the dispatch | |
%% list used for routing. | |
--spec set_env(ranch:ref(), atom(), any()) -> ok. | |
+-spec set_env(barrel:ref(), atom(), any()) -> ok. | |
set_env(Ref, Name, Value) -> | |
- Opts = ranch:get_protocol_options(Ref), | |
+ {Handler, Opts} = barrel:get_protocol_conf(Ref), | |
{_, Env} = lists:keyfind(env, 1, Opts), | |
Env2 = [{Name, Value}|lists:keydelete(Name, 1, Env)], | |
Opts2 = lists:keyreplace(env, 1, Opts, {env, Env2}), | |
- ok = ranch:set_protocol_options(Ref, Opts2). | |
+ ok = barrel:set_protocol_conf(Ref, Handler, Opts2). | |
diff --git a/src/cowboy_client.erl b/src/cowboy_client.erl | |
index b5f96b3..93a1fe7 100644 | |
--- a/src/cowboy_client.erl | |
+++ b/src/cowboy_client.erl | |
@@ -108,11 +108,11 @@ request(Method, URL, Headers, Body, Client=#client{ | |
raw_request(Data, Client2). | |
parse_url(<< "https://", Rest/binary >>) -> | |
- parse_url(Rest, ranch_ssl); | |
+ parse_url(Rest, barrel_ssl); | |
parse_url(<< "http://", Rest/binary >>) -> | |
- parse_url(Rest, ranch_tcp); | |
+ parse_url(Rest, barrel_tcp); | |
parse_url(URL) -> | |
- parse_url(URL, ranch_tcp). | |
+ parse_url(URL, barrel_tcp). | |
parse_url(URL, Transport) -> | |
case binary:split(URL, <<"/">>) of | |
@@ -126,9 +126,9 @@ parse_url(URL, Transport) -> | |
parse_peer(Peer, Transport) -> | |
case binary:split(Peer, <<":">>) of | |
- [Host] when Transport =:= ranch_tcp -> | |
+ [Host] when Transport =:= barrel_tcp -> | |
{binary_to_list(Host), 80}; | |
- [Host] when Transport =:= ranch_ssl -> | |
+ [Host] when Transport =:= barrel_ssl -> | |
{binary_to_list(Host), 443}; | |
[Host, Port] -> | |
{binary_to_list(Host), list_to_integer(binary_to_list(Port))} | |
diff --git a/src/cowboy_protocol.erl b/src/cowboy_protocol.erl | |
index b42f524..176684a 100644 | |
--- a/src/cowboy_protocol.erl | |
+++ b/src/cowboy_protocol.erl | |
@@ -49,10 +49,9 @@ | |
-module(cowboy_protocol). | |
%% API. | |
--export([start_link/4]). | |
+-export([init/4]). | |
%% Internal. | |
--export([init/4]). | |
-export([parse_request/3]). | |
-export([parse_host/2]). | |
-export([resume/6]). | |
@@ -91,13 +90,6 @@ | |
}). | |
%% API. | |
- | |
-%% @doc Start an HTTP protocol process. | |
--spec start_link(ranch:ref(), inet:socket(), module(), opts()) -> {ok, pid()}. | |
-start_link(Ref, Socket, Transport, Opts) -> | |
- Pid = spawn_link(?MODULE, init, [Ref, Socket, Transport, Opts]), | |
- {ok, Pid}. | |
- | |
%% Internal. | |
%% @doc Faster alternative to proplists:get_value/3. | |
@@ -109,8 +101,8 @@ get_value(Key, Opts, Default) -> | |
end. | |
%% @private | |
--spec init(ranch:ref(), inet:socket(), module(), opts()) -> ok. | |
-init(Ref, Socket, Transport, Opts) -> | |
+-spec init(barrel:ref(), inet:socket(), module(), opts()) -> ok. | |
+init(Ref, Transport, Socket, Opts) -> | |
Compress = get_value(compress, Opts, false), | |
MaxEmptyLines = get_value(max_empty_lines, Opts, 5), | |
MaxHeaderNameLength = get_value(max_header_name_length, Opts, 64), | |
@@ -123,7 +115,6 @@ init(Ref, Socket, Transport, Opts) -> | |
OnRequest = get_value(onrequest, Opts, undefined), | |
OnResponse = get_value(onresponse, Opts, undefined), | |
Timeout = get_value(timeout, Opts, 5000), | |
- ok = ranch:accept_ack(Ref), | |
wait_request(<<>>, #state{socket=Socket, transport=Transport, | |
middlewares=Middlewares, compress=Compress, env=Env, | |
max_empty_lines=MaxEmptyLines, max_keepalive=MaxKeepalive, | |
diff --git a/src/cowboy_req.erl b/src/cowboy_req.erl | |
index 66abcf8..73aa966 100644 | |
--- a/src/cowboy_req.erl | |
+++ b/src/cowboy_req.erl | |
@@ -1494,28 +1494,28 @@ status(B) when is_binary(B) -> B. | |
url_test() -> | |
{undefined, _} = | |
- url(#http_req{transport=ranch_tcp, host= <<>>, port= undefined, | |
+ url(#http_req{transport=barrel_tcp, host= <<>>, port= undefined, | |
path= <<>>, qs= <<>>, pid=self()}), | |
{<<"http://localhost/path">>, _ } = | |
- url(#http_req{transport=ranch_tcp, host= <<"localhost">>, port=80, | |
+ url(#http_req{transport=barrel_tcp, host= <<"localhost">>, port=80, | |
path= <<"/path">>, qs= <<>>, pid=self()}), | |
{<<"http://localhost:443/path">>, _} = | |
- url(#http_req{transport=ranch_tcp, host= <<"localhost">>, port=443, | |
+ url(#http_req{transport=barrel_tcp, host= <<"localhost">>, port=443, | |
path= <<"/path">>, qs= <<>>, pid=self()}), | |
{<<"http://localhost:8080/path">>, _} = | |
- url(#http_req{transport=ranch_tcp, host= <<"localhost">>, port=8080, | |
+ url(#http_req{transport=barrel_tcp, host= <<"localhost">>, port=8080, | |
path= <<"/path">>, qs= <<>>, pid=self()}), | |
{<<"http://localhost:8080/path?dummy=2785">>, _} = | |
- url(#http_req{transport=ranch_tcp, host= <<"localhost">>, port=8080, | |
+ url(#http_req{transport=barrel_tcp, host= <<"localhost">>, port=8080, | |
path= <<"/path">>, qs= <<"dummy=2785">>, pid=self()}), | |
{<<"https://localhost/path">>, _} = | |
- url(#http_req{transport=ranch_ssl, host= <<"localhost">>, port=443, | |
+ url(#http_req{transport=barrel_ssl, host= <<"localhost">>, port=443, | |
path= <<"/path">>, qs= <<>>, pid=self()}), | |
{<<"https://localhost:8443/path">>, _} = | |
- url(#http_req{transport=ranch_ssl, host= <<"localhost">>, port=8443, | |
+ url(#http_req{transport=barrel_ssl, host= <<"localhost">>, port=8443, | |
path= <<"/path">>, qs= <<>>, pid=self()}), | |
{<<"https://localhost:8443/path?dummy=2785">>, _} = | |
- url(#http_req{transport=ranch_ssl, host= <<"localhost">>, port=8443, | |
+ url(#http_req{transport=barrel_ssl, host= <<"localhost">>, port=8443, | |
path= <<"/path">>, qs= <<"dummy=2785">>, pid=self()}), | |
ok. | |
diff --git a/src/cowboy_spdy.erl b/src/cowboy_spdy.erl | |
index 182e6da..2d6a526 100644 | |
--- a/src/cowboy_spdy.erl | |
+++ b/src/cowboy_spdy.erl | |
@@ -84,7 +84,7 @@ | |
%% @doc Start a SPDY protocol process. | |
-spec start_link(any(), inet:socket(), module(), any()) -> {ok, pid()}. | |
-start_link(Ref, Socket, Transport, Opts) -> | |
+start_link(Ref, Transport, Socket, Opts) -> | |
proc_lib:start_link(?MODULE, init, | |
[self(), Ref, Socket, Transport, Opts]). | |
@@ -99,7 +99,7 @@ get_value(Key, Opts, Default) -> | |
end. | |
%% @private | |
--spec init(pid(), ranch:ref(), inet:socket(), module(), opts()) -> ok. | |
+-spec init(pid(), barrel:ref(), inet:socket(), module(), opts()) -> ok. | |
init(Parent, Ref, Socket, Transport, Opts) -> | |
process_flag(trap_exit, true), | |
ok = proc_lib:init_ack(Parent, {ok, self()}), | |
@@ -113,7 +113,7 @@ init(Parent, Ref, Socket, Transport, Opts) -> | |
_ = zlib:deflateSetDictionary(Zdef, ?ZDICT), | |
Zinf = zlib:open(), | |
ok = zlib:inflateInit(Zinf), | |
- ok = ranch:accept_ack(Ref), | |
+ ok = barrel:accept_ack(Ref), | |
loop(#state{parent=Parent, socket=Socket, transport=Transport, | |
middlewares=Middlewares, env=Env, onrequest=OnRequest, | |
onresponse=OnResponse, peer=Peer, zdef=Zdef, zinf=Zinf}). | |
diff --git a/src/cowboy_websocket.erl b/src/cowboy_websocket.erl | |
index 073d7c6..0e3353e 100644 | |
--- a/src/cowboy_websocket.erl | |
+++ b/src/cowboy_websocket.erl | |
@@ -71,8 +71,7 @@ | |
| {suspend, module(), atom(), [any()]} | |
when Req::cowboy_req:req(), Env::cowboy_middleware:env(). | |
upgrade(Req, Env, Handler, HandlerOpts) -> | |
- {_, Ref} = lists:keyfind(listener, 1, Env), | |
- ranch:remove_connection(Ref), | |
+ {_, _Ref} = lists:keyfind(listener, 1, Env), | |
[Socket, Transport] = cowboy_req:get([socket, transport], Req), | |
State = #state{env=Env, socket=Socket, transport=Transport, | |
handler=Handler, handler_opts=HandlerOpts}, | |
diff --git a/test/autobahn_SUITE.erl b/test/autobahn_SUITE.erl | |
index 68a9221..af12920 100644 | |
--- a/test/autobahn_SUITE.erl | |
+++ b/test/autobahn_SUITE.erl | |
@@ -37,7 +37,7 @@ groups() -> | |
init_per_suite(Config) -> | |
application:start(crypto), | |
- application:start(ranch), | |
+ application:start(barrel), | |
application:start(cowboy), | |
%% /tmp must be used as the parent directory for the virtualenv because | |
%% the directory names used in CT are so long that the interpreter path | |
@@ -57,7 +57,7 @@ init_per_suite(Config) -> | |
end_per_suite(_Config) -> | |
os:cmd("deactivate"), | |
application:stop(cowboy), | |
- application:stop(ranch), | |
+ application:stop(barrel), | |
application:stop(crypto), | |
ok. | |
diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl | |
index 2135fdc..223aa4c 100644 | |
--- a/test/http_SUITE.erl | |
+++ b/test/http_SUITE.erl | |
@@ -191,7 +191,7 @@ groups() -> | |
init_per_suite(Config) -> | |
application:start(crypto), | |
- application:start(ranch), | |
+ application:start(barrel), | |
application:start(cowboy), | |
Dir = ?config(priv_dir, Config) ++ "/static", | |
ct_helper:create_static_dir(Dir), | |
@@ -201,23 +201,23 @@ end_per_suite(Config) -> | |
Dir = ?config(static_dir, Config), | |
ct_helper:delete_static_dir(Dir), | |
application:stop(cowboy), | |
- application:stop(ranch), | |
+ application:stop(barrel), | |
application:stop(crypto), | |
ok. | |
init_per_group(http, Config) -> | |
- Transport = ranch_tcp, | |
+ Transport = barrel_tcp, | |
{ok, _} = cowboy:start_http(http, 100, [{port, 0}], [ | |
{env, [{dispatch, init_dispatch(Config)}]}, | |
{max_keepalive, 50}, | |
{timeout, 500} | |
]), | |
- Port = ranch:get_port(http), | |
+ {ok, Port} = barrel:get_port(http), | |
{ok, Client} = cowboy_client:init([]), | |
[{scheme, <<"http">>}, {port, Port}, {opts, []}, | |
{transport, Transport}, {client, Client}|Config]; | |
init_per_group(https, Config) -> | |
- Transport = ranch_ssl, | |
+ Transport = barrel_ssl, | |
{_, Cert, Key} = ct_helper:make_certs(), | |
Opts = [{cert, Cert}, {key, Key}], | |
application:start(asn1), | |
@@ -228,24 +228,24 @@ init_per_group(https, Config) -> | |
{max_keepalive, 50}, | |
{timeout, 500} | |
]), | |
- Port = ranch:get_port(https), | |
+ {ok, Port} = barrel:get_port(https), | |
{ok, Client} = cowboy_client:init(Opts), | |
[{scheme, <<"https">>}, {port, Port}, {opts, Opts}, | |
{transport, Transport}, {client, Client}|Config]; | |
init_per_group(http_compress, Config) -> | |
- Transport = ranch_tcp, | |
+ Transport = barrel_tcp, | |
{ok, _} = cowboy:start_http(http_compress, 100, [{port, 0}], [ | |
{compress, true}, | |
{env, [{dispatch, init_dispatch(Config)}]}, | |
{max_keepalive, 50}, | |
{timeout, 500} | |
]), | |
- Port = ranch:get_port(http_compress), | |
+ {ok, Port} = barrel:get_port(http_compress), | |
{ok, Client} = cowboy_client:init([]), | |
[{scheme, <<"http">>}, {port, Port}, {opts, []}, | |
{transport, Transport}, {client, Client}|Config]; | |
init_per_group(https_compress, Config) -> | |
- Transport = ranch_ssl, | |
+ Transport = barrel_ssl, | |
{_, Cert, Key} = ct_helper:make_certs(), | |
Opts = [{cert, Cert}, {key, Key}], | |
application:start(asn1), | |
@@ -257,54 +257,54 @@ init_per_group(https_compress, Config) -> | |
{max_keepalive, 50}, | |
{timeout, 500} | |
]), | |
- Port = ranch:get_port(https_compress), | |
+ {ok, Port} = barrel:get_port(https_compress), | |
{ok, Client} = cowboy_client:init(Opts), | |
[{scheme, <<"https">>}, {port, Port}, {opts, Opts}, | |
{transport, Transport}, {client, Client}|Config]; | |
init_per_group(onrequest, Config) -> | |
- Transport = ranch_tcp, | |
+ Transport = barrel_tcp, | |
{ok, _} = cowboy:start_http(onrequest, 100, [{port, 0}], [ | |
{env, [{dispatch, init_dispatch(Config)}]}, | |
{max_keepalive, 50}, | |
{onrequest, fun onrequest_hook/1}, | |
{timeout, 500} | |
]), | |
- Port = ranch:get_port(onrequest), | |
+ {ok, Port} = barrel:get_port(onrequest), | |
{ok, Client} = cowboy_client:init([]), | |
[{scheme, <<"http">>}, {port, Port}, {opts, []}, | |
{transport, Transport}, {client, Client}|Config]; | |
init_per_group(onresponse, Config) -> | |
- Transport = ranch_tcp, | |
+ Transport = barrel_tcp, | |
{ok, _} = cowboy:start_http(onresponse, 100, [{port, 0}], [ | |
{env, [{dispatch, init_dispatch(Config)}]}, | |
{max_keepalive, 50}, | |
{onresponse, fun onresponse_hook/4}, | |
{timeout, 500} | |
]), | |
- Port = ranch:get_port(onresponse), | |
+ {ok, Port} = barrel:get_port(onresponse), | |
{ok, Client} = cowboy_client:init([]), | |
[{scheme, <<"http">>}, {port, Port}, {opts, []}, | |
{transport, Transport}, {client, Client}|Config]; | |
init_per_group(onresponse_capitalize, Config) -> | |
- Transport = ranch_tcp, | |
+ Transport = barrel_tcp, | |
{ok, _} = cowboy:start_http(onresponse_capitalize, 100, [{port, 0}], [ | |
{env, [{dispatch, init_dispatch(Config)}]}, | |
{max_keepalive, 50}, | |
{onresponse, fun onresponse_capitalize_hook/4}, | |
{timeout, 500} | |
]), | |
- Port = ranch:get_port(onresponse_capitalize), | |
+ {ok, Port} = barrel:get_port(onresponse_capitalize), | |
{ok, Client} = cowboy_client:init([]), | |
[{scheme, <<"http">>}, {port, Port}, {opts, []}, | |
{transport, Transport}, {client, Client}|Config]; | |
init_per_group(set_env, Config) -> | |
- Transport = ranch_tcp, | |
+ Transport = barrel_tcp, | |
{ok, _} = cowboy:start_http(set_env, 100, [{port, 0}], [ | |
{env, [{dispatch, []}]}, | |
{max_keepalive, 50}, | |
{timeout, 500} | |
]), | |
- Port = ranch:get_port(set_env), | |
+ {ok, Port} = barrel:get_port(set_env), | |
{ok, Client} = cowboy_client:init([]), | |
[{scheme, <<"http">>}, {port, Port}, {opts, []}, | |
{transport, Transport}, {client, Client}|Config]. | |
@@ -644,7 +644,7 @@ http10_chunkless(Config) -> | |
http10_hostless(Config) -> | |
Port10 = ?config(port, Config) + 10, | |
Name = list_to_atom("http10_hostless_" ++ integer_to_list(Port10)), | |
- ranch:start_listener(Name, 5, | |
+ barrel:start_listener(Name, 5, | |
?config(transport, Config), ?config(opts, Config) ++ [{port, Port10}], | |
cowboy_protocol, [ | |
{env, [{dispatch, cowboy_router:compile([ | |
diff --git a/test/spdy_SUITE.erl b/test/spdy_SUITE.erl | |
index 469e5d6..6afc732 100644 | |
--- a/test/spdy_SUITE.erl | |
+++ b/test/spdy_SUITE.erl | |
@@ -40,7 +40,7 @@ groups() -> | |
init_per_suite(Config) -> | |
application:start(crypto), | |
- application:start(ranch), | |
+ application:start(barrel), | |
application:start(cowboy), | |
application:start(asn1), | |
application:start(public_key), | |
@@ -56,7 +56,7 @@ end_per_suite(Config) -> | |
application:stop(public_key), | |
application:stop(asn1), | |
application:stop(cowboy), | |
- application:stop(ranch), | |
+ application:stop(barrel), | |
application:stop(crypto), | |
ok. | |
@@ -66,7 +66,7 @@ init_per_group(Name, Config) -> | |
{ok, _} = cowboy:start_spdy(Name, 100, Opts ++ [{port, 0}], [ | |
{env, [{dispatch, init_dispatch(Config)}]} | |
]), | |
- Port = ranch:get_port(Name), | |
+ {ok, Port} = barrel:get_port(Name), | |
[{port, Port}|Config]. | |
end_per_group(Name, _) -> | |
diff --git a/test/ws_SUITE.erl b/test/ws_SUITE.erl | |
index d2a0888..b47c291 100644 | |
--- a/test/ws_SUITE.erl | |
+++ b/test/ws_SUITE.erl | |
@@ -70,13 +70,13 @@ groups() -> | |
init_per_suite(Config) -> | |
application:start(crypto), | |
- application:start(ranch), | |
+ application:start(barrel), | |
application:start(cowboy), | |
Config. | |
end_per_suite(_Config) -> | |
application:stop(cowboy), | |
- application:stop(ranch), | |
+ application:stop(barrel), | |
application:stop(crypto), | |
ok. | |
@@ -85,7 +85,7 @@ init_per_group(ws, Config) -> | |
{env, [{dispatch, init_dispatch()}]}, | |
{compress, true} | |
]), | |
- Port = ranch:get_port(ws), | |
+ {ok, Port} = barrel:get_port(ws), | |
[{port, Port}|Config]. | |
end_per_group(Listener, _Config) -> | |
@@ -618,7 +618,7 @@ ws_timeout_hibernate(Config) -> | |
ok. | |
ws_timeout_cancel(Config) -> | |
- %% Erlang messages to a socket should not cancel the timeout | |
+ %% Erlang messages to a socket should not cancel the timeout | |
{port, Port} = lists:keyfind(port, 1, Config), | |
{ok, Socket} = gen_tcp:connect("localhost", Port, | |
[binary, {active, false}, {packet, raw}]), | |
@@ -645,7 +645,7 @@ ws_timeout_cancel(Config) -> | |
ok. | |
ws_timeout_reset(Config) -> | |
- %% Erlang messages across a socket should reset the timeout | |
+ %% Erlang messages across a socket should reset the timeout | |
{port, Port} = lists:keyfind(port, 1, Config), | |
{ok, Socket} = gen_tcp:connect("localhost", Port, | |
[binary, {active, false}, {packet, raw}]), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment