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
Post a Comment