JdkClientHttpRequest does not support Content-Length 0
This commit ensures the correct HttpRequest.BodyPublisher is used with Content-Length 0. Closes gh-31451
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2023-2023 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -129,9 +129,12 @@ class JdkClientHttpRequest extends AbstractStreamingClientHttpRequest {
|
||||
BYTE_MAPPER, this.executor);
|
||||
|
||||
long contentLength = headers.getContentLength();
|
||||
if (contentLength != -1) {
|
||||
if (contentLength > 0) {
|
||||
return HttpRequest.BodyPublishers.fromPublisher(outputStreamPublisher, contentLength);
|
||||
}
|
||||
else if (contentLength == 0) {
|
||||
return HttpRequest.BodyPublishers.noBody();
|
||||
}
|
||||
else {
|
||||
return HttpRequest.BodyPublishers.fromPublisher(outputStreamPublisher);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user