Description
This is a bug introduced by pull request 423 addressing HTTPCLIENT-1756.
The solution for better logging includes the beginning of the response body in the exception. Unfortunately, this also impacts the response body in all cases, even on success (200 OK). As a result, returnContent() will only ever return a String from the first 256 bytes.
This code triggers the bug:
final String jsonResponse = Request.get("https://www.neowsapp.com/rest/v1/feed/today") .execute() .returnContent().asString(); System.out.println(jsonResponse); System.out.println(jsonResponse.length());
The problem occurs in the overriding ContentResponseHandler#handleResponse() method. It extracts the response body into a byte array, limiting the length to MAX_MESSAGE_LENGTH (which is 256).
A better solution would be to modify the overridden method of AbstractHttpClientResponseHandler and add the truncated body to the exception thrown there instead of just consuming the response body entity.
Attachments
Issue Links
- is caused by
-
HTTPCLIENT-1756 Response Body on response codes over 300 should not be ignored
- Resolved