How to avoid chunked responses in a request handler?

I have a request handler (java) that writes output to the response. If this output is large (above 50.000 bytes), it gets chunked: in the headers “Transfer-Encoding: chunked” appears. How to avoid the response to get chunked? (I want the complete data in one message because I am creating a mock service that should realistically mimic another system and I am not sure that a chunked response arrives correctly. The other system [also Mendix] is missing data.) Sent response headers: HTTP/1.1 200 OK Server: nginx Date: Fri, 13 Dec 2019 14:38:09 GMT Transfer-Encoding: chunked Connection: keep-alive Cache-Control: no-store X-Frame-Options: sameorigin X-Vcap-Request-Id: c7958452-8ae7-4541-6133-2c175be01caf Strict-Transport-Security: max-age=31536000   Java snippet: protected void processRequest(IMxRuntimeRequest req, IMxRuntimeResponse response, String pathRemainder) throws Exception { (...) response.getWriter().write(responsePayload); response.getWriter().close();  
1 answers

Looks like I fixed it myself by writing in parts:

final int partLength = 10000;
Writer writer = response.getWriter();
if (responsePayload != null) {
	// write to the response in parts of 10,000 characters to avoid a chunked response
	for (int offset = 0; offset < responseLen; offset += partLength) {
		int curPartLen = partLength;
		if (offset + curPartLen > responseLen) {
			curPartLen = responseLen - offset;
		writer.write(responsePayload, offset, curPartLen);