Skip to content

Commit 4aee416

Browse files
committed
[java] Adding allowHosts to GeckoDriverService
Fixes #11264
1 parent b7d7c49 commit 4aee416

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

java/src/org/openqa/selenium/firefox/GeckoDriverService.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.io.IOException;
3232
import java.time.Duration;
3333
import java.util.ArrayList;
34+
import java.util.Arrays;
3435
import java.util.HashMap;
3536
import java.util.List;
3637
import java.util.Map;
@@ -143,9 +144,10 @@ protected boolean hasShutdownEndpoint() {
143144
*/
144145
@AutoService(DriverService.Builder.class)
145146
public static class Builder extends FirefoxDriverService.Builder<
146-
GeckoDriverService, GeckoDriverService.Builder> {
147+
GeckoDriverService, GeckoDriverService.Builder> {
147148

148149
private FirefoxBinary firefoxBinary;
150+
private String allowHosts;
149151

150152
public Builder() {
151153
}
@@ -177,6 +179,17 @@ public Builder usingFirefoxBinary(FirefoxBinary firefoxBinary) {
177179
return this;
178180
}
179181

182+
/**
183+
* Values of the Host header to allow for incoming requests.
184+
*
185+
* @param allowHosts Space-separated list of host names.
186+
* @return A self reference.
187+
*/
188+
public GeckoDriverService.Builder withAllowHosts(String allowHosts) {
189+
this.allowHosts = allowHosts;
190+
return this;
191+
}
192+
180193
@Override
181194
protected List<String> createArgs() {
182195
List<String> args = new ArrayList<>();
@@ -198,8 +211,13 @@ protected List<String> createArgs() {
198211
args.add("-b");
199212
args.add(e.getPath());
200213
});
214+
// If the binary stays null, GeckoDriver will be responsible for finding Firefox on the
215+
// PATH or via a capability.
216+
}
217+
if (allowHosts != null) {
218+
args.add("--allow-hosts");
219+
args.addAll(Arrays.asList(allowHosts.split(" ")));
201220
}
202-
// If the binary stays null, GeckoDriver will be responsible for finding Firefox on the PATH or via a capability.
203221
return unmodifiableList(args);
204222
}
205223

0 commit comments

Comments
 (0)