Skip to content

Commit

Permalink
Fix unsafe verb on /json/new
Browse files Browse the repository at this point in the history
  • Loading branch information
gorghoa committed Jan 18, 2024
1 parent 3de6b9f commit 9e8967f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/http.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ defmodule ChromeRemoteInterface.HTTP do
@type success_http_response :: {:ok, Map.t()}
@type error_http_response :: {:error, any()}

@spec call(ChromeRemoteInterface.Server.t(), String.t()) ::
@spec call(ChromeRemoteInterface.Server.t(), String.t(), []) ::
success_http_response | error_http_response
def call(server, path) do
def call(server, path, opts \\ []) do
server
|> execute_request(path)
|> execute_request(path, opts)
|> handle_response()
end

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

defp execute_request(server, path) do
:hackney.request(:get, http_url(server, path), [], <<>>, path_encode_fun: & &1)
defp execute_request(server, path, opts \\ []) do
verb = opts[:verb] || :get
:hackney.request(verb, http_url(server, path), [], <<>>, path_encode_fun: & &1)
end

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

0 comments on commit 9e8967f

Please sign in to comment.