Debian Codegraph @

test/rfc7538_SUITE.erl

raw
1 %% Copyright (c) Loïc Hoguin <[email protected]>
2 %%
3 %% Permission to use, copy, modify, and/or distribute this software for any
4 %% purpose with or without fee is hereby granted, provided that the above
5 %% copyright notice and this permission notice appear in all copies.
6 %%
7 %% THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 %% WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 %% MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 %% ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 %% WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 %% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13 %% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14
15 -module(rfc7538_SUITE).
16 -compile(export_all).
17 -compile(nowarn_export_all).
18
19 -import(ct_helper, [config/2]).
20 -import(ct_helper, [doc/1]).
21 -import(cowboy_test, [gun_open/1]).
22
23 all() ->
24 cowboy_test:common_all().
25
26 groups() ->
27 cowboy_test:common_groups(ct_helper:all(?MODULE)).
28
29 init_per_group(Name, Config) ->
30 cowboy_test:init_common_groups(Name, Config, ?MODULE).
31
32 end_per_group(Name, _) ->
33 cowboy_test:stop_group(Name).
34
35 init_dispatch(_) ->
36 cowboy_router:compile([{"[...]", [
37 {"/resp/:key[/:arg]", resp_h, []}
38 ]}]).
39
40 status_code_308(Config) ->
41 doc("The 308 Permanent Redirect status code can be sent. (RFC7538 3)"),
42 ConnPid = gun_open(Config),
43 Ref = gun:get(ConnPid, "/resp/reply2/308", [
44 {<<"accept-encoding">>, <<"gzip">>}
45 ]),
46 {response, _, 308, _} = gun:await(ConnPid, Ref),
47 ok.
48
49 %% @todo
50 % The server SHOULD generate a Location header field ([RFC7231],
51 % Section 7.1.2) in the response containing a preferred URI reference
52 % for the new permanent URI.