0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-16 05:00:24 +00:00

Switch to Ranch for connection handling

This is the first of many API incompatible changes.

You have been warned.
This commit is contained in:
Loïc Hoguin 2012-08-27 11:50:35 +02:00
parent 50e5a616dc
commit e4124de2c7
35 changed files with 133 additions and 1066 deletions

View file

@ -326,13 +326,14 @@ file_contents(Req, #state{filepath=Filepath,
-spec content_function(module(), inet:socket(), binary()) ->
fun(() -> {sent, non_neg_integer()}).
content_function(Transport, Socket, Filepath) ->
%% `file:sendfile/2' will only work with the `cowboy_tcp_transport'
%% `file:sendfile/2' will only work with the `ranch_tcp'
%% transport module. SSL or future SPDY transports that require the
%% content to be encrypted or framed as the content is sent.
%% content to be encrypted or framed as the content is sent
%% will use the fallback mechanism.
case erlang:function_exported(file, sendfile, 2) of
false ->
fun() -> sfallback(Transport, Socket, Filepath) end;
_ when Transport =/= cowboy_tcp_transport ->
_ when Transport =/= ranch_tcp ->
fun() -> sfallback(Transport, Socket, Filepath) end;
true ->
fun() -> sendfile(Socket, Filepath) end