diff options
author | Loïc Hoguin <[email protected]> | 2013-04-03 13:47:12 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2013-04-03 13:47:12 +0200 |
commit | 2b56bb498f82860fb8783a7ee4d69a1d5696c5c9 (patch) | |
tree | 3d4a306dcf005fcb7437aaf91325d6489f9af9bf | |
parent | ce1d8862c093b31a2e3ba0a072b58b697a6b55de (diff) | |
download | cowboy-2b56bb498f82860fb8783a7ee4d69a1d5696c5c9.tar.gz cowboy-2b56bb498f82860fb8783a7ee4d69a1d5696c5c9.tar.bz2 cowboy-2b56bb498f82860fb8783a7ee4d69a1d5696c5c9.zip |
Update Ranch to 0.8.0
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | examples/elixir_hello_world/mix.exs | 2 | ||||
-rw-r--r-- | guide/middlewares.md | 2 | ||||
-rw-r--r-- | rebar.config | 2 | ||||
-rw-r--r-- | src/cowboy_protocol.erl | 14 | ||||
-rw-r--r-- | src/cowboy_websocket.erl | 4 |
6 files changed, 13 insertions, 13 deletions
@@ -1,7 +1,7 @@ # See LICENSE for licensing information. PROJECT = cowboy -RANCH_VSN = 0.6.2 +RANCH_VSN = 0.8.0 ERLC_OPTS ?= -Werror +debug_info +warn_export_all +warn_export_vars \ +warn_shadow_vars +warn_obsolete_guard # +bin_opt_info +warn_missing_spec diff --git a/examples/elixir_hello_world/mix.exs b/examples/elixir_hello_world/mix.exs index 065024d..9f113a6 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.6.2"}, + [ {:ranch, github: "extend/ranch", tag: "0.8.0"}, {:cowboy, github: "extend/cowboy"} ] end end diff --git a/guide/middlewares.md b/guide/middlewares.md index b5f055c..a1f1f8d 100644 --- a/guide/middlewares.md +++ b/guide/middlewares.md @@ -48,7 +48,7 @@ the routing information. It is a list of tuples with the first element being an atom and the second any Erlang term. Two values in the environment are reserved: - * `listener` contains the pid of the listener process + * `listener` contains the name of the listener * `result` contains the result of the processing The `listener` value is always defined. The `result` value can be diff --git a/rebar.config b/rebar.config index 64f8d0e..0ddc628 100644 --- a/rebar.config +++ b/rebar.config @@ -1,3 +1,3 @@ {deps, [ - {ranch, ".*", {git, "git://github.com/extend/ranch.git", "0.6.2"}} + {ranch, ".*", {git, "git://github.com/extend/ranch.git", "0.8.0"}} ]}. diff --git a/src/cowboy_protocol.erl b/src/cowboy_protocol.erl index 78e3b78..be351b7 100644 --- a/src/cowboy_protocol.erl +++ b/src/cowboy_protocol.erl @@ -84,9 +84,9 @@ %% API. %% @doc Start an HTTP protocol process. --spec start_link(pid(), inet:socket(), module(), any()) -> {ok, pid()}. -start_link(ListenerPid, Socket, Transport, Opts) -> - Pid = spawn_link(?MODULE, init, [ListenerPid, Socket, Transport, Opts]), +-spec start_link(any(), inet:socket(), module(), any()) -> {ok, pid()}. +start_link(Ref, Socket, Transport, Opts) -> + Pid = spawn_link(?MODULE, init, [Ref, Socket, Transport, Opts]), {ok, Pid}. %% Internal. @@ -100,8 +100,8 @@ get_value(Key, Opts, Default) -> end. %% @private --spec init(pid(), inet:socket(), module(), any()) -> ok. -init(ListenerPid, Socket, Transport, Opts) -> +-spec init(any(), inet:socket(), module(), any()) -> ok. +init(Ref, Socket, Transport, Opts) -> Compress = get_value(compress, Opts, false), MaxEmptyLines = get_value(max_empty_lines, Opts, 5), MaxHeaderNameLength = get_value(max_header_name_length, Opts, 64), @@ -110,11 +110,11 @@ init(ListenerPid, Socket, Transport, Opts) -> MaxKeepalive = get_value(max_keepalive, Opts, 100), MaxRequestLineLength = get_value(max_request_line_length, Opts, 4096), Middlewares = get_value(middlewares, Opts, [cowboy_router, cowboy_handler]), - Env = [{listener, ListenerPid}|get_value(env, Opts, [])], + Env = [{listener, Ref}|get_value(env, Opts, [])], OnRequest = get_value(onrequest, Opts, undefined), OnResponse = get_value(onresponse, Opts, undefined), Timeout = get_value(timeout, Opts, 5000), - ok = ranch:accept_ack(ListenerPid), + 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_websocket.erl b/src/cowboy_websocket.erl index 7bb5e74..b5075c0 100644 --- a/src/cowboy_websocket.erl +++ b/src/cowboy_websocket.erl @@ -63,8 +63,8 @@ | {suspend, module(), atom(), [any()]} when Req::cowboy_req:req(), Env::cowboy_middleware:env(). upgrade(Req, Env, Handler, HandlerOpts) -> - {_, ListenerPid} = lists:keyfind(listener, 1, Env), - ranch_listener:remove_connection(ListenerPid), + {_, Ref} = lists:keyfind(listener, 1, Env), + ranch:remove_connection(Ref), [Socket, Transport] = cowboy_req:get([socket, transport], Req), State = #state{env=Env, socket=Socket, transport=Transport, handler=Handler, handler_opts=HandlerOpts}, |