|
17 | 17 | -export([standard_options/1]). |
18 | 18 | -export([simple_allowed_get/1]). |
19 | 19 | -export([simple_allowed_credentials_get/1]). |
| 20 | +-export([simple_exposed_headers/1]). |
20 | 21 | -export([actual_options/1]). |
21 | 22 | -export([preflight_method/1]). |
22 | 23 | -export([preflight_allowed_method/1]). |
@@ -46,6 +47,7 @@ groups() -> |
46 | 47 | standard_options, |
47 | 48 | simple_allowed_get, |
48 | 49 | simple_allowed_credentials_get, |
| 50 | + simple_exposed_headers, |
49 | 51 | actual_options, |
50 | 52 | preflight_method, |
51 | 53 | preflight_allowed_method, |
@@ -168,6 +170,21 @@ simple_allowed_credentials_get(Config) -> |
168 | 170 | {_, Origin} = lists:keyfind(<<"access-control-allow-origin">>, 1, Headers), |
169 | 171 | {_, <<"true">>} = lists:keyfind(<<"access-control-allow-credentials">>, 1, Headers). |
170 | 172 |
|
| 173 | +simple_exposed_headers(Config) -> |
| 174 | + Origin = <<"http://example.com">>, |
| 175 | + Exposed = [<<"x-first">>, <<"x-second">>], |
| 176 | + {ok, 204, Headers, _} = |
| 177 | + request(<<"GET">>, |
| 178 | + [{<<"Origin">>, Origin}], |
| 179 | + [{allowed_origins, Origin}, |
| 180 | + {allowed_methods, <<"GET">>}, |
| 181 | + {exposed_headers, Exposed}], |
| 182 | + Config), |
| 183 | + {_, Origin} = lists:keyfind(<<"access-control-allow-origin">>, 1, Headers), |
| 184 | + {_, ExposedList} = lists:keyfind(<<"access-control-expose-headers">>, 1, Headers), |
| 185 | + Exposed = cowboy_http:nonempty_list(ExposedList, fun cowboy_http:token/2), |
| 186 | + false = lists:keyfind(<<"access-control-allow-credentials">>, 1, Headers). |
| 187 | + |
171 | 188 | actual_options(Config) -> |
172 | 189 | %% OPTIONS request without Access-Control-Request-Method is not a pre-flight request. |
173 | 190 | Origin = <<"http://example.com">>, |
|
0 commit comments