The response get truncated after 16321 bytes.  Please let me know what is
best way to wait and in order to consume entire request payload.

Thanks,
Bhavesh

On Wed, Feb 26, 2020 at 4:34 PM Bhavesh Mistry <mistry.p.bhav...@gmail.com>
wrote:

> Hi Tomcat Team,
>
> I have servlet filter for all requests to cache the entire PUT/POST
> Payload.   When content is large 4KB or more, I am getting partial content
> when I read from HttpServletRequest.getInputStream().  But I but 10 seconds
> wait before consuming the input stream, I am getting entire content.  Can
> you please let me know what is the correct way to wait for the entire
> content is ready to consume from the tomcat servlet request input stream?
>
>
> Filter Code:
> If I put Thread.sleep(100000) at begin of filter, I am getting full
> content.
>
> @Override
> protected void doFilterInternal(HttpServletRequest httpServletRequest, 
> HttpServletResponse httpServletResponse, FilterChain filterChain) throws 
> ServletException, IOException {
>     CachedBodyHttpServletRequest cachedBodyHttpServletRequest = new 
> CachedBodyHttpServletRequest(httpServletRequest);
>     filterChain.doFilter(cachedBodyHttpServletRequest, httpServletResponse);
> }
>
> // Wrapper to cache content.
>
> public CachedBodyHttpServletRequest(HttpServletRequest request) throws 
> IOException {
>     super(request);
>     ServletInputStream inputStream = request.getInputStream();
>     final int len = request.getContentLength();
>     if (len >= 0) {
>         cachedBody = new byte[len];
>         ByteStreams.readFully(inputStream, cachedBody);
>     } else {
>         cachedBody = ByteStreams.toByteArray(inputStream);
>     }
> }
>
>
> Thanks,
>
> Bhavesh
>

Reply via email to