The cause is that you’re trying to set a HTTP header in Tomcat that contains non-ASCII characters (e.g. the Location header as part of a redirect or the Content-Disposition header for a file download). This has started appearing since switching to a new Tomcat version (9.0.73 at least has this issue).
The solution is to properly encode the HTTP headers. We’re doing this with
name = URLEncoder.encode(name, 'UTF-8')
For more in-depth information see these two bug reports
- https://bz.apache.org/bugzilla/show_bug.cgi?id=66512
- https://bz.apache.org/bugzilla/show_bug.cgi?id=66196
The stack location at which this occurred for us is
at org.apache.tomcat.util.buf.MessageBytes.toBytesSimple(MessageBytes.java:292) at org.apache.tomcat.util.buf.MessageBytes.toBytes(MessageBytes.java:261) at org.apache.coyote.ajp.AjpMessage.appendBytes(AjpMessage.java:172) at org.apache.coyote.ajp.AjpProcessor.prepareResponse(AjpProcessor.java:1011)