[Grid] Changing host header before forwarding commands to the driver
A better fix for commit
import org.openqa.selenium.remote.tracing.Tracer;
import java.net.URL;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
import static org.openqa.selenium.remote.http.HttpMethod.DELETE;
@@ -62,7 +64,10 @@ protected ProtocolConvertingSession(
@Override
public HttpResponse execute(HttpRequest req) {
String host = "host";
- req.removeHeader(host);
+ StreamSupport.stream(req.getHeaderNames().spliterator(), true)
+ .filter(host::equalsIgnoreCase)
+ .collect(Collectors.toList())
+ .forEach(req::removeHeader);
req.addHeader(host, String.format("%s:%s", getUri().getHost(), getUri().getPort()));
HttpResponse res = handler.execute(req);
if (req.getMethod() == DELETE && killUrl.equals(req.getUri())) {
