File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
java/src/org/openqa/selenium/remote/http/jdk Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change 24
24
import org .openqa .selenium .remote .http .HttpResponse ;
25
25
26
26
import java .io .ByteArrayInputStream ;
27
- import java .io .InputStream ;
28
27
import java .net .URI ;
29
28
import java .net .URLEncoder ;
30
29
import java .net .http .HttpRequest .BodyPublishers ;
30
+ import java .util .List ;
31
31
import java .util .Objects ;
32
32
import java .util .stream .Collectors ;
33
33
import java .util .stream .StreamSupport ;
37
37
class JdkHttpMessages {
38
38
39
39
private final ClientConfig config ;
40
+ private static final List <String > IGNORE_HEADERS =
41
+ List .of ("content-length" , "connection" , "host" );
40
42
41
43
public JdkHttpMessages (ClientConfig config ) {
42
44
this .config = Objects .requireNonNull (config , "Client config" );
@@ -83,9 +85,8 @@ public java.net.http.HttpRequest createRequest(HttpRequest req) {
83
85
}
84
86
85
87
for (String name : req .getHeaderNames ()) {
86
- // Avoid explicitly setting content-length
87
- // This prevents the IllegalArgumentException that states 'restricted header name: "Content-Length"'
88
- if (name .equalsIgnoreCase ("content-length" )) {
88
+ // This prevents the IllegalArgumentException that states 'restricted header name: ...'
89
+ if (IGNORE_HEADERS .contains (name .toLowerCase ())) {
89
90
continue ;
90
91
}
91
92
for (String value : req .getHeaders (name )) {
You can’t perform that action at this time.
0 commit comments