Skip to content

Commit ccf6278

Browse files
krmahadevandiemol
authored andcommitted
JDKHttpClient: Handle RQST with no Body [POST/PUT]
Fixes: SeleniumHQ#11342
1 parent 26dd4de commit ccf6278

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

java/src/org/openqa/selenium/remote/http/jdk/JdkHttpMessages.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,12 @@ private BodyPublisher notChunkingBodyPublisher(HttpRequest req) {
115115

116116
if (length == null) {
117117
// read the data into a byte array to know the length
118-
return BodyPublishers.ofByteArray(Contents.bytes(req.getContent()));
118+
byte[] bytes = Contents.bytes(req.getContent());
119+
if (bytes.length == 0) {
120+
//Looks like we were given a request with no payload.
121+
return BodyPublishers.noBody();
122+
}
123+
return BodyPublishers.ofByteArray(bytes);
119124
}
120125

121126
// we know the length of the request and use it

0 commit comments

Comments
 (0)