if (type == null) {
coyoteResponse.setContentType(null);
return;
}
AstMediaType m = null;
HttpParser hp = new HttpParser(new StringReader(type));
try {
m = hp.MediaType();
} catch (ParseException e) {
// Invalid - Assume no charset and just pass through whatever
// the user provided.
coyoteResponse.setContentTypeNoCharset(type);
return;
}
coyoteResponse.setContentTypeNoCharset(m.toStringNoCharset());
String charset = m.getCharset();
if (charset != null) {
// Ignore charset if getWriter() has already been called
if (!usingWriter) {
coyoteResponse.setCharacterEncoding(charset);
isCharacterEncodingSet = true;