Skip to content

Commit

Permalink
JDKHttpClient: Handle RQST with no Body [POST/PUT] (#11445)
Browse files Browse the repository at this point in the history
Fixes: #11342
  • Loading branch information
krmahadevan authored Dec 20, 2022
1 parent c744c1e commit 83d3d46
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ private BodyPublisher notChunkingBodyPublisher(HttpRequest req) {

if (length == null) {
// read the data into a byte array to know the length
return BodyPublishers.ofByteArray(Contents.bytes(req.getContent()));
byte[] bytes = Contents.bytes(req.getContent());
if (bytes.length == 0) {
//Looks like we were given a request with no payload.
return BodyPublishers.noBody();
}
return BodyPublishers.ofByteArray(bytes);
}

// we know the length of the request and use it
Expand Down

0 comments on commit 83d3d46

Please sign in to comment.