-
Sub-task
-
Resolution: Delivered
-
P4
-
25
Two new methods `java.net.http.HttpResponse.BodyHandlers.limiting(BodyHandler downstreamHandler, long capacity)` and `java.net.http.HttpResponse.BodySubsribers.limiting(BodySubscriber downstreamSubscriber, long capacity)` are added to the `HttpClient` API. These methods extend an existing `BodyHandler` or `BodySubscriber` with the ability to limit the number of response body bytes that the application is willing to accept in response to an HTTP request. Upon reaching the limit when reading the response body, an `IOException` will be raised and reported to the downstream subscriber. The subscription will be cancelled, and any further response body bytes will be discarded. This makes it possible for the application to control the maximum amount of bytes that it wants to accept from the server.