java - How do I send an HTTP response without Transfer Encoding: chunked? -


i have java servlet responds twilio api. appears twilio not support chunked transfer responses using. how can avoid using transfer-encoding: chunked?

here code:

// response httpservletresponse // xml string xml in response.getwriter().write(xml); response.getwriter().flush(); 

i using jetty servlet container.

try setting content-length before writing stream. don't forget calculate amount of bytes according correct encoding, e.g.:

final byte[] content = xml.getbytes("utf-8"); response.setcontentlength(content.length); response.setcontenttype("text/xml"); // or "text/xml; charset=utf-8" response.setcharacterencoding("utf-8");  final outputstream out = response.getoutputstream(); out.write(content); 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -