@@ -8,9 +8,9 @@ defmodule SafeURL do
88 allowed to make requests.
99
1010 You can use `allowed?/2` or `validate/2` to check if a
11- URL is safe to call, or just call it directly via `get/4`
12- which will validate it automatically before calling, and
13- return an error if it is not .
11+ URL is safe to call. If the `HTTPoison` application is
12+ available, you can also call `get/4` directly which will
13+ validate the host before making an HTTP request .
1414
1515
1616 ## Examples
@@ -27,6 +27,8 @@ defmodule SafeURL do
2727 iex> SafeURL.validate("http://230.10.10.10/", block_reserved: false)
2828 :ok
2929
30+ # If HTTPoison is available:
31+
3032 iex> SafeURL.get("https://10.0.0.1/ssrf.txt")
3133 {:error, :restricted}
3234
@@ -190,7 +192,8 @@ defmodule SafeURL do
190192 return `{:error, :restricted}`.
191193
192194 `headers` and `httpoison_options` will be passed directly to
193- `HTTPoison` when the request is executed.
195+ `HTTPoison` when the request is executed. This function will
196+ raise if `HTTPoison` if not available.
194197
195198 See `allowed?/2` for more details on URL validation.
196199
@@ -211,7 +214,7 @@ defmodule SafeURL do
211214
212215 """
213216 @ spec get ( binary ( ) , Keyword . t ( ) , HTTPoison . headers ( ) , Keyword . t ( ) ) ::
214- { :ok , HTTPoison.Response . t ( ) } | { :error , :restricted }
217+ { :ok , HTTPoison.Response . t ( ) } | { :error , :restricted } | no_return ( )
215218 def get ( url , options \\ [ ] , headers \\ [ ] , httpoison_options \\ [ ] ) do
216219 unless function_exported? ( HTTPoison , :get , 3 ) do
217220 raise "HTTPoison.get/3 not available"
0 commit comments