[grid] removing `content-length` header for `GET` requests
This helps
because Netty tends to timeout when a GET has a `content-length`
header (which is seen as a bad practice), however, the server
should not timeout.
package org.openqa.selenium.remote.http.netty;
-import static org.asynchttpclient.Dsl.request;
-import static org.openqa.selenium.remote.http.Contents.empty;
-import static org.openqa.selenium.remote.http.Contents.memoize;
-
import com.google.common.base.Strings;
import org.asynchttpclient.Dsl;
import java.net.URI;
+import static org.asynchttpclient.Dsl.request;
+import static org.openqa.selenium.remote.http.Contents.empty;
+import static org.openqa.selenium.remote.http.Contents.memoize;
+
class NettyMessages {
private NettyMessages() {
@@ -61,6 +61,11 @@ protected static Request toNettyRequest(
}
}
+ // Netty tends to timeout when a GET request has a 'Content-Length' header
+ if (request.getMethod().equals(HttpMethod.GET) && request.getHeader("Content-Length") != null) {
+ request.removeHeader("Content-Length");
+ }
+
for (String name : request.getHeaderNames()) {
for (String value : request.getHeaders(name)) {
builder.addHeader(name, value);
