Closed gpsfl closed 3 years ago
Hi @gpsfl.
I believe this is already possible with JDK's BodyPublishers
.
var sizedBodyPublisher = BodyPublishers.fromPublisher(BodyPublishers.ofInputStream(() -> null), contentLength);
Isn't this what you're suggesting?
Oh, you're right. The naming might be a bit counter intuitive there. Thanks a lot!
Sometimes you want to provide a body publisher which can't automatically determine the size (ofInputStream for example), however you know the size of the stream through meta data or similar. For such cases it would be great to have a body publisher to which you can manually provide a content length. Something like:
which can be used with a method like
MoreBodyHandlers.withSize(delegate, length)