Filter response returning only part of the content

SexyMF :

I have the below method that extracts the response and wraps it in a wrapper class.

With the debugger, I can see that responseContent has the full content as it should be, but when it is printed to the screen, only part of the request is returning.

I can see that the variable data has the entire value as it should have.

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
    ContentCachingResponseWrapper responseWrapper = new ContentCachingResponseWrapper((HttpServletResponse) response);
    chain.doFilter(request, responseWrapper);
    String responseContent = new String(responseWrapper.getContentAsByteArray());
    BasicResponse<Object> fullResponse = new BasicResponse<>();
    fullResponse.setData(new ObjectMapper().readValue(responseContent, Object.class));
    String data = new ObjectMapper().writeValueAsString(fullResponse);
    response.getWriter().write(data);//data has the entire value
    response.getWriter().close();
}
Karol Dowbecki :

Most likely the response Content-Length header is set with value lower than the new data length. Make sure to set this header with new value which matches the new data length.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=105628&siteId=1