rfc7538_SUITE.erl 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. %% Copyright (c) 2018, Loïc Hoguin <essen@ninenines.eu>
  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. -module(rfc7538_SUITE).
  15. -compile(export_all).
  16. -compile(nowarn_export_all).
  17. -import(ct_helper, [config/2]).
  18. -import(ct_helper, [doc/1]).
  19. -import(cowboy_test, [gun_open/1]).
  20. all() ->
  21. cowboy_test:common_all().
  22. groups() ->
  23. cowboy_test:common_groups(ct_helper:all(?MODULE)).
  24. init_per_group(Name, Config) ->
  25. cowboy_test:init_common_groups(Name, Config, ?MODULE).
  26. end_per_group(Name, _) ->
  27. cowboy:stop_listener(Name).
  28. init_dispatch(_) ->
  29. cowboy_router:compile([{"[...]", [
  30. {"/resp/:key[/:arg]", resp_h, []}
  31. ]}]).
  32. status_code_308(Config) ->
  33. doc("The 308 Permanent Redirect status code can be sent. (RFC7538 3)"),
  34. ConnPid = gun_open(Config),
  35. Ref = gun:get(ConnPid, "/resp/reply2/308", [
  36. {<<"accept-encoding">>, <<"gzip">>}
  37. ]),
  38. {response, _, 308, _} = gun:await(ConnPid, Ref),
  39. ok.
  40. %% @todo
  41. % The server SHOULD generate a Location header field ([RFC7231],
  42. % Section 7.1.2) in the response containing a preferred URI reference
  43. % for the new permanent URI.