Skip to content

Commit 3707a56

Browse files
committed
JDKHttpClient: Handle RQST with no Body [POST/PUT]
Fixes: SeleniumHQ#11342
1 parent 8d1fcf0 commit 3707a56

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

Lines changed: 6 additions & 1 deletion
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)