Restrict size of response from client side

Viewed 13

Is there a way to restrict the size of the http response content while forming the http request? We use the following piece of code to execute a GET request and intend to handle responses of size <= 1MB

 HttpUriRequest httpUriRequest = new HttpGet(this.getResolvedEndpoint());
 HttpClientContext context = HttpClientContext.create();
 context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
 HttpResponse response = httpClient.execute(httpUriRequest, context);
 HttpEntity entity = response.getEntity();

axios provides support for a parameter maxContentLength which helps in capping the size of the http response size. We are looking for an equivalent solution in JAVA.

0 Answers
Related