aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/test
diff options
context:
space:
mode:
authorHenrik Nord <[email protected]>2015-10-27 12:46:47 +0100
committerHenrik Nord <[email protected]>2015-10-27 12:46:47 +0100
commit5a36d9f631d1f22ea3b6ecc40dd647c33795a688 (patch)
tree9fb87ed248c0fc5b0a6763e60dbcbd278d5ad93f /lib/inets/test
parent804ee95d85b50b1789c4506e5c83a6aa1316f33a (diff)
parent3b28f0d9bbc9e5745fb95e48e6daf9179461116b (diff)
downloadotp-5a36d9f631d1f22ea3b6ecc40dd647c33795a688.tar.gz
otp-5a36d9f631d1f22ea3b6ecc40dd647c33795a688.tar.bz2
otp-5a36d9f631d1f22ea3b6ecc40dd647c33795a688.zip
Merge branch 'scrapinghub/http_uri_scheme_validation' into maint
* scrapinghub/http_uri_scheme_validation: inets: scheme validation fun for http_uri OTP-13071
Diffstat (limited to 'lib/inets/test')
-rw-r--r--lib/inets/test/uri_SUITE.erl23
1 files changed, 22 insertions, 1 deletions
diff --git a/lib/inets/test/uri_SUITE.erl b/lib/inets/test/uri_SUITE.erl
index bfcd7bd339..2642b8fd4e 100644
--- a/lib/inets/test/uri_SUITE.erl
+++ b/lib/inets/test/uri_SUITE.erl
@@ -49,7 +49,8 @@ all() ->
queries,
fragments,
escaped,
- hexed_query
+ hexed_query,
+ scheme_validation
].
%%--------------------------------------------------------------------
@@ -175,6 +176,26 @@ hexed_query(Config) when is_list(Config) ->
verify_uri(URI2, Verify2),
verify_uri(URI3, Verify3).
+scheme_validation(Config) when is_list(Config) ->
+ {ok, {http,[],"localhost",80,"/",""}} =
+ http_uri:parse("http://localhost#fragment"),
+
+ ValidationFun =
+ fun("http") -> valid;
+ (_) -> {error, bad_scheme}
+ end,
+
+ {ok, {http,[],"localhost",80,"/",""}} =
+ http_uri:parse("http://localhost#fragment",
+ [{scheme_validation_fun, ValidationFun}]),
+ {error, bad_scheme} =
+ http_uri:parse("https://localhost#fragment",
+ [{scheme_validation_fun, ValidationFun}]),
+ %% non-fun scheme_validation_fun works as no option passed
+ {ok, {https,[],"localhost",443,"/",""}} =
+ http_uri:parse("https://localhost#fragment",
+ [{scheme_validation_fun, none}]).
+
%%--------------------------------------------------------------------
%% Internal Functions ------------------------------------------------