Skip to content

Commit 5482877

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

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
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

lib/session.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ defmodule ChromeRemoteInterface.Session do
4545
@spec new_page(Server.t()) :: HTTP.success_http_response() | HTTP.error_http_response()
4646
def new_page(server) do
4747
server
48-
|> HTTP.call("/json/new")
48+
|> HTTP.call("/json/new", verb: :put)
4949
end
5050

5151
@doc """

0 commit comments

Comments
 (0)