Even when setting the content length, chunked encoding appears to be used when reponses get over a certain size (20 to 30 kilobyte range), which confuses me. Any further thoughts?
- Guus On 25 April 2015 at 12:00, Simone Bordet <[email protected]> wrote: > Hi, > > On Sat, Apr 25, 2015 at 11:26 AM, Guus der Kinderen > <[email protected]> wrote: > > Hi, > > > > I'm using WriteListener to send data from a Jetty 9.2.9 based Servlet in > a > > response. Chunked encoding must be prevented. To do so, the buffer size > of > > the response is set to match the length of the data. This appears to work > > for smaller packets, but larger packets (larger dan 20-something > kilobytes) > > cause chunked encoding to re-appear. How do I prevent this? > > > > static class WriteListenerImpl implements WriteListener { > > > > private final AsyncContext context; > > private final byte[] data; > > > > public WriteListenerImpl(AsyncContext context, byte[] data) { > > this.context = context; > > this.data = data; > > } > > > > @Override > > public void onWritePossible() throws IOException { > > context.getResponse().setBufferSize(data.length); > > context.getResponse().getOutputStream().write(data); > > context.complete(); > > } > > } > > Calling response.setContentLength(data.length) should do it. > > -- > Simone Bordet > ---- > http://cometd.org > http://webtide.com > http://intalio.com > Developer advice, training, services and support > from the Jetty & CometD experts. > Intalio, the modern way to build business applications. > _______________________________________________ > jetty-users mailing list > [email protected] > To change your delivery options, retrieve your password, or unsubscribe > from this list, visit > https://dev.eclipse.org/mailman/listinfo/jetty-users >
_______________________________________________ jetty-users mailing list [email protected] To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/jetty-users
