Skip to content

Commit

Permalink
Use default HTTP client when communicating with services
Browse files Browse the repository at this point in the history
This allows to share a logic for setting default headers (e.g User-Agent)
and any additional processing required to make HTTP requests.

Closes #6662
  • Loading branch information
p0deje committed May 3, 2019
1 parent 4a8948c commit 8389311
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions rb/lib/selenium/webdriver/common/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ def build_process(*command)
end

def connect_to_server
Net::HTTP.start(@host, @port) do |http|
http.open_timeout = STOP_TIMEOUT / 2
http.read_timeout = STOP_TIMEOUT / 2

yield http
end
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
http.close
end

def find_free_port
Expand All @@ -164,7 +164,7 @@ def stop_process
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?
Expand Down

0 comments on commit 8389311

Please sign in to comment.