Use default HTTP client when communicating with services
This allows to share a logic for setting default headers (e.g User-Agent)
and any additional processing required to make HTTP requests.
Closes
@@ -135,12 +135,12 @@ module Selenium
end
def connect_to_server
- Net::HTTP.start(@host, @port) do |http|
+ http = Selenium::WebDriver::Remote::Http::Default.new
http.open_timeout = STOP_TIMEOUT / 2
http.read_timeout = STOP_TIMEOUT / 2
-
+ http.server_url = uri
yield http
- end
+ http.close
end
def find_free_port
@@ -164,7 +164,7 @@ module Selenium
def stop_server
return if process_exited?
- connect_to_server { |http| http.get('/shutdown') }
+ connect_to_server { |http| http.call(:get, '/shutdown', nil) }
end
def process_running?
