Skip to content

Commit 9e8967f

Browse files
author
Rodrigue Villetard
committed
Fix unsafe verb on /json/new
1 parent 3de6b9f commit 9e8967f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lib/http.ex

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ defmodule ChromeRemoteInterface.HTTP do
66
@type success_http_response :: {:ok, Map.t()}
77
@type error_http_response :: {:error, any()}
88

9-
@spec call(ChromeRemoteInterface.Server.t(), String.t()) ::
9+
@spec call(ChromeRemoteInterface.Server.t(), String.t(), []) ::
1010
success_http_response | error_http_response
11-
def call(server, path) do
11+
def call(server, path, opts \\ []) do
1212
server
13-
|> execute_request(path)
13+
|> execute_request(path, opts)
1414
|> handle_response()
1515
end
1616

@@ -22,8 +22,9 @@ defmodule ChromeRemoteInterface.HTTP do
2222
"http://#{server.host}:#{server.port}#{path}"
2323
end
2424

25-
defp execute_request(server, path) do
26-
:hackney.request(:get, http_url(server, path), [], <<>>, path_encode_fun: & &1)
25+
defp execute_request(server, path, opts \\ []) do
26+
verb = opts[:verb] || :get
27+
:hackney.request(verb, http_url(server, path), [], <<>>, path_encode_fun: & &1)
2728
end
2829

2930
defp handle_response({:ok, status_code, _response_headers, client_ref}) do

0 commit comments

Comments
 (0)