Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit dd30a29

Browse files
author
whhone
committed
curl options in HttpCommandExecutor::remoteExecute()
change the interface from ($cmd, $timeout) to ($cmd, $curl_opts) so that we can handle all curl opts nicer. To set the original timeout, passing array(CURLOPT_CONNECTTIMEOUT_MS => $timeout) as the $curl_opts.
1 parent f58c179 commit dd30a29

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

lib/remote/HttpCommandExecutor.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,26 +131,25 @@ public function execute($name, array $params = array()) {
131131
* sessionId : the session id if needed
132132
* name : the name of the command
133133
* parameters : the parameters of the command required
134-
* @param timeout Milliseconds to wait while trying to connect (defaults to 5 minutes)
134+
* @param curl_opts An array of curl options.
135135
*
136136
* @return array The response of the command.
137137
*/
138-
public static function remoteExecute($command, $timeout = 300000) {
138+
public static function remoteExecute($command, $curl_opts = array()) {
139139
if (!isset(self::$commands[$command['name']])) {
140140
throw new Exception($command['name']." is not a valid command.");
141141
}
142142
$raw = self::$commands[$command['name']];
143-
$extra_opts = array(CURLOPT_CONNECTTIMEOUT_MS => $timeout);
144143

145144
if ($command['name'] == 'newSession') {
146-
$extra_opts[CURLOPT_FOLLOWLOCATION] = true;
145+
$curl_opts[CURLOPT_FOLLOWLOCATION] = true;
147146
}
148147

149148
return self::curl(
150149
$raw['method'],
151150
sprintf("%s%s", $command['url'], $raw['url']),
152151
$command,
153-
$extra_opts
152+
$curl_opts
154153
);
155154
}
156155

lib/remote/RemoteWebDriver.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,20 @@ class RemoteWebDriver implements WebDriver {
2323
public function __construct(
2424
$url = 'http://localhost:4444/wd/hub',
2525
$desired_capabilities = array(),
26-
$timeout = 300000) {
26+
$timeout_in_ms = 300000) {
2727

2828
$url = preg_replace('#/+$#', '', $url);
2929
$command = array(
3030
'url' => $url,
3131
'name' => 'newSession',
3232
'parameters' => array('desiredCapabilities' => $desired_capabilities),
3333
);
34-
$response = HttpCommandExecutor::remoteExecute($command, $timeout);
34+
$response = HttpCommandExecutor::remoteExecute(
35+
$command,
36+
array(
37+
CURLOPT_CONNECTTIMEOUT_MS => $timeout_in_ms,
38+
)
39+
);
3540

3641
$this->executor = new HttpCommandExecutor(
3742
$url,

0 commit comments

Comments
 (0)