mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 12:20:24 +00:00
Remove outdated multipart tests
They have equivalents in req_SUITE.
This commit is contained in:
parent
f425f7478a
commit
3eb7693e4f
3 changed files with 0 additions and 103 deletions
|
@ -160,8 +160,6 @@ init_dispatch(Config) ->
|
||||||
[{etag, ?MODULE, do_etag_gen}]}},
|
[{etag, ?MODULE, do_etag_gen}]}},
|
||||||
{"/static_specify_file/[...]", cowboy_static,
|
{"/static_specify_file/[...]", cowboy_static,
|
||||||
{file, config(static_dir, Config) ++ "/style.css"}},
|
{file, config(static_dir, Config) ++ "/style.css"}},
|
||||||
{"/multipart", http_multipart, []},
|
|
||||||
{"/multipart/large", http_multipart_stream, []},
|
|
||||||
{"/echo/body", http_echo_body, []},
|
{"/echo/body", http_echo_body, []},
|
||||||
{"/echo/body_qs", http_body_qs, []},
|
{"/echo/body_qs", http_body_qs, []},
|
||||||
{"/crash/content-length", input_crash_h, content_length},
|
{"/crash/content-length", input_crash_h, content_length},
|
||||||
|
@ -446,62 +444,6 @@ keepalive_stream_loop(Config) ->
|
||||||
end || Ref <- Refs],
|
end || Ref <- Refs],
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
multipart(Config) ->
|
|
||||||
ConnPid = gun_open(Config),
|
|
||||||
Body = <<
|
|
||||||
"This is a preamble."
|
|
||||||
"\r\n--OHai\r\nX-Name:answer\r\n\r\n42"
|
|
||||||
"\r\n--OHai\r\nServer:Cowboy\r\n\r\nIt rocks!\r\n"
|
|
||||||
"\r\n--OHai--\r\n"
|
|
||||||
"This is an epilogue."
|
|
||||||
>>,
|
|
||||||
Ref = gun:post(ConnPid, "/multipart",
|
|
||||||
[{<<"content-type">>, <<"multipart/x-makes-no-sense; boundary=OHai">>}],
|
|
||||||
Body),
|
|
||||||
{response, nofin, 200, _} = gun:await(ConnPid, Ref),
|
|
||||||
{ok, RespBody} = gun:await_body(ConnPid, Ref),
|
|
||||||
Parts = binary_to_term(RespBody),
|
|
||||||
Parts = [
|
|
||||||
{[{<<"x-name">>, <<"answer">>}], <<"42">>},
|
|
||||||
{[{<<"server">>, <<"Cowboy">>}], <<"It rocks!\r\n">>}
|
|
||||||
],
|
|
||||||
ok.
|
|
||||||
|
|
||||||
multipart_chunked(Config) ->
|
|
||||||
ConnPid = gun_open(Config),
|
|
||||||
Body = <<
|
|
||||||
"This is a preamble."
|
|
||||||
"\r\n--OHai\r\nX-Name:answer\r\n\r\n42"
|
|
||||||
"\r\n--OHai\r\nServer:Cowboy\r\n\r\nIt rocks!\r\n"
|
|
||||||
"\r\n--OHai--\r\n"
|
|
||||||
"This is an epilogue."
|
|
||||||
>>,
|
|
||||||
Ref = gun:post(ConnPid, "/multipart",
|
|
||||||
[{<<"content-type">>, <<"multipart/x-makes-no-sense; boundary=OHai">>}]),
|
|
||||||
gun:data(ConnPid, Ref, fin, Body),
|
|
||||||
{response, nofin, 200, _} = gun:await(ConnPid, Ref),
|
|
||||||
{ok, RespBody} = gun:await_body(ConnPid, Ref),
|
|
||||||
Parts = binary_to_term(RespBody),
|
|
||||||
Parts = [
|
|
||||||
{[{<<"x-name">>, <<"answer">>}], <<"42">>},
|
|
||||||
{[{<<"server">>, <<"Cowboy">>}], <<"It rocks!\r\n">>}
|
|
||||||
],
|
|
||||||
ok.
|
|
||||||
|
|
||||||
multipart_large(Config) ->
|
|
||||||
ConnPid = gun_open(Config),
|
|
||||||
Boundary = "----------",
|
|
||||||
Big = << 0:9000000/unit:8 >>,
|
|
||||||
Bigger = << 0:9999999/unit:8 >>,
|
|
||||||
Body = ["--", Boundary, "\r\ncontent-length: 9000000\r\n\r\n", Big, "\r\n",
|
|
||||||
"--", Boundary, "\r\ncontent-length: 9999999\r\n\r\n", Bigger, "\r\n",
|
|
||||||
"--", Boundary, "--\r\n"],
|
|
||||||
Ref = gun:post(ConnPid, "/multipart/large",
|
|
||||||
[{<<"content-type">>, ["multipart/x-large; boundary=", Boundary]}],
|
|
||||||
Body),
|
|
||||||
{response, fin, 200, _} = gun:await(ConnPid, Ref),
|
|
||||||
ok.
|
|
||||||
|
|
||||||
do_nc(Config, Input) ->
|
do_nc(Config, Input) ->
|
||||||
Cat = os:find_executable("cat"),
|
Cat = os:find_executable("cat"),
|
||||||
Nc = os:find_executable("nc"),
|
Nc = os:find_executable("nc"),
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
%% Feel free to use, reuse and abuse the code in this file.
|
|
||||||
|
|
||||||
-module(http_multipart).
|
|
||||||
|
|
||||||
-export([init/2]).
|
|
||||||
|
|
||||||
init(Req, Opts) ->
|
|
||||||
{Result, Req2} = acc_multipart(Req, []),
|
|
||||||
{ok, cowboy_req:reply(200, #{}, term_to_binary(Result), Req2), Opts}.
|
|
||||||
|
|
||||||
acc_multipart(Req, Acc) ->
|
|
||||||
case cowboy_req:read_part(Req) of
|
|
||||||
{ok, Headers, Req2} ->
|
|
||||||
{ok, Body, Req3} = cowboy_req:read_part_body(Req2),
|
|
||||||
acc_multipart(Req3, [{Headers, Body}|Acc]);
|
|
||||||
{done, Req2} ->
|
|
||||||
{lists:reverse(Acc), Req2}
|
|
||||||
end.
|
|
|
@ -1,27 +0,0 @@
|
||||||
%% Feel free to use, reuse and abuse the code in this file.
|
|
||||||
|
|
||||||
-module(http_multipart_stream).
|
|
||||||
|
|
||||||
-export([init/2]).
|
|
||||||
|
|
||||||
init(Req, Opts) ->
|
|
||||||
Req2 = multipart(Req),
|
|
||||||
{ok, cowboy_req:reply(200, Req2), Opts}.
|
|
||||||
|
|
||||||
multipart(Req) ->
|
|
||||||
case cowboy_req:read_part(Req) of
|
|
||||||
{ok, [{<<"content-length">>, BinLength}], Req2} ->
|
|
||||||
Length = binary_to_integer(BinLength),
|
|
||||||
{Length, Req3} = stream_body(Req2, 0),
|
|
||||||
multipart(Req3);
|
|
||||||
{done, Req2} ->
|
|
||||||
Req2
|
|
||||||
end.
|
|
||||||
|
|
||||||
stream_body(Req, N) ->
|
|
||||||
case cowboy_req:read_part_body(Req) of
|
|
||||||
{ok, Data, Req2} ->
|
|
||||||
{N + byte_size(Data), Req2};
|
|
||||||
{more, Data, Req2} ->
|
|
||||||
stream_body(Req2, N + byte_size(Data))
|
|
||||||
end.
|
|
Loading…
Add table
Add a link
Reference in a new issue