aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--ebin/cowboy.app2
-rw-r--r--src/cowboy_http2.erl2
-rw-r--r--src/cowboy_iolists.erl100
4 files changed, 3 insertions, 103 deletions
diff --git a/Makefile b/Makefile
index b036a1b..c2b339c 100644
--- a/Makefile
+++ b/Makefile
@@ -15,7 +15,7 @@ CT_OPTS += -ct_hooks cowboy_ct_hook [] # -boot start_sasl
LOCAL_DEPS = crypto
DEPS = cowlib ranch
-dep_cowlib = git https://github.com/ninenines/cowlib 2.3.0
+dep_cowlib = git https://github.com/ninenines/cowlib master
dep_ranch = git https://github.com/ninenines/ranch 1.5.0
DOC_DEPS = asciideck
diff --git a/ebin/cowboy.app b/ebin/cowboy.app
index 9916e6e..a23b580 100644
--- a/ebin/cowboy.app
+++ b/ebin/cowboy.app
@@ -1,7 +1,7 @@
{application, 'cowboy', [
{description, "Small, fast, modern HTTP server."},
{vsn, "2.4.0"},
- {modules, ['cowboy','cowboy_app','cowboy_bstr','cowboy_children','cowboy_clear','cowboy_clock','cowboy_compress_h','cowboy_constraints','cowboy_handler','cowboy_http','cowboy_http2','cowboy_iolists','cowboy_loop','cowboy_metrics_h','cowboy_middleware','cowboy_req','cowboy_rest','cowboy_router','cowboy_static','cowboy_stream','cowboy_stream_h','cowboy_sub_protocol','cowboy_sup','cowboy_tls','cowboy_tracer_h','cowboy_websocket']},
+ {modules, ['cowboy','cowboy_app','cowboy_bstr','cowboy_children','cowboy_clear','cowboy_clock','cowboy_compress_h','cowboy_constraints','cowboy_handler','cowboy_http','cowboy_http2','cowboy_loop','cowboy_metrics_h','cowboy_middleware','cowboy_req','cowboy_rest','cowboy_router','cowboy_static','cowboy_stream','cowboy_stream_h','cowboy_sub_protocol','cowboy_sup','cowboy_tls','cowboy_tracer_h','cowboy_websocket']},
{registered, [cowboy_sup,cowboy_clock]},
{applications, [kernel,stdlib,crypto,cowlib,ranch]},
{mod, {cowboy_app, []}},
diff --git a/src/cowboy_http2.erl b/src/cowboy_http2.erl
index 420be2c..dfda305 100644
--- a/src/cowboy_http2.erl
+++ b/src/cowboy_http2.erl
@@ -907,7 +907,7 @@ send_data(State=#state{socket=Socket, transport=Transport, opts=Opts,
{State#state{local_window=ConnWindow - IolistSize},
Stream#stream{local=IsFin, local_window=StreamWindow - IolistSize}};
true ->
- {Iolist, More} = cowboy_iolists:split(MaxSendSize, Iolist0),
+ {Iolist, More} = cow_iolists:split(MaxSendSize, Iolist0),
Transport:send(Socket, cow_http2:data(StreamID, nofin, Iolist)),
send_data(State#state{local_window=ConnWindow - MaxSendSize},
Stream#stream{local_window=StreamWindow - MaxSendSize},
diff --git a/src/cowboy_iolists.erl b/src/cowboy_iolists.erl
deleted file mode 100644
index a49e7ed..0000000
--- a/src/cowboy_iolists.erl
+++ /dev/null
@@ -1,100 +0,0 @@
-%% Copyright (c) 2017, Loïc Hoguin <[email protected]>
-%%
-%% Permission to use, copy, modify, and/or distribute this software for any
-%% purpose with or without fee is hereby granted, provided that the above
-%% copyright notice and this permission notice appear in all copies.
-%%
-%% THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-%% WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-%% MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-%% ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-%% WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-%% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-%% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
--module(cowboy_iolists).
-
--export([split/2]).
-
--ifdef(TEST).
--include_lib("proper/include/proper.hrl").
--endif.
-
--spec split(non_neg_integer(), iodata()) -> {iodata(), iodata()}.
-split(N, Iolist) ->
- case split(N, Iolist, []) of
- {ok, Before, After} ->
- {Before, After};
- {more, _, Before} ->
- {lists:reverse(Before), <<>>}
- end.
-
-split(0, Rest, Acc) ->
- {ok, lists:reverse(Acc), Rest};
-split(N, [], Acc) ->
- {more, N, Acc};
-split(N, Binary, Acc) when byte_size(Binary) =< N ->
- {ok, lists:reverse([Binary|Acc]), <<>>};
-split(N, Binary, Acc) when is_binary(Binary) ->
- << Before:N/binary, After/bits >> = Binary,
- {ok, lists:reverse([Before|Acc]), After};
-split(N, [Binary|Tail], Acc) when byte_size(Binary) =< N ->
- split(N - byte_size(Binary), Tail, [Binary|Acc]);
-split(N, [Binary|Tail], Acc) when is_binary(Binary) ->
- << Before:N/binary, After/bits >> = Binary,
- {ok, lists:reverse([Before|Acc]), [After|Tail]};
-split(N, [Char|Tail], Acc) when is_integer(Char) ->
- split(N - 1, Tail, [Char|Acc]);
-split(N, [List|Tail], Acc0) ->
- case split(N, List, Acc0) of
- {ok, Before, After} ->
- IolistSize = iolist_size(Before),
- if
- IolistSize < N ->
- split(N - IolistSize, [After|Tail], lists:reverse(Before));
- true ->
- {ok, Before, [After|Tail]}
- end;
- {more, More, Acc} ->
- split(More, Tail, Acc)
- end.
-
--ifdef(TEST).
-
-split_test_() ->
- Tests = [
- {10, "Hello world!", "Hello worl", "d!"},
- {10, <<"Hello world!">>, "Hello worl", "d!"},
- {10, ["He", [<<"llo">>], $\s, [["world"], <<"!">>]], "Hello worl", "d!"},
- {10, ["Hello "|<<"world!">>], "Hello worl", "d!"},
- {10, "Hello!", "Hello!", ""},
- {10, <<"Hello!">>, "Hello!", ""},
- {10, ["He", [<<"ll">>], $o, [["!"]]], "Hello!", ""},
- {10, ["Hel"|<<"lo!">>], "Hello!", ""},
- {10, [[<<>>|<<>>], [], <<"Hello world!">>], "Hello worl", "d!"},
- {10, [[<<"He">>|<<"llo">>], [$\s], <<"world!">>], "Hello worl", "d!"}
- ],
- [{iolist_to_binary(V), fun() ->
- {B, A} = split(N, V),
- true = iolist_to_binary(RB) =:= iolist_to_binary(B),
- true = iolist_to_binary(RA) =:= iolist_to_binary(A)
- end} || {N, V, RB, RA} <- Tests].
-
-prop_split_test() ->
- ?FORALL({N, Input},
- {non_neg_integer(), iolist()},
- begin
- Size = iolist_size(Input),
- {Before, After} = split(N, Input),
- if
- N >= Size ->
- ((iolist_size(After) =:= 0)
- andalso iolist_to_binary(Before) =:= iolist_to_binary(Input));
- true ->
- <<ExpectBefore:N/binary, ExpectAfter/bits>> = iolist_to_binary(Input),
- (ExpectBefore =:= iolist_to_binary(Before))
- andalso (ExpectAfter =:= iolist_to_binary(After))
- end
- end).
-
--endif.