HttpServer.java 文件源码

java
阅读 39 收藏 0 点赞 0 评论 0

项目:big-c 作者:
@Override
public void doFilter(ServletRequest request, 
                     ServletResponse response,
                     FilterChain chain
                     ) throws IOException, ServletException {
  HttpServletRequestWrapper quoted = 
    new RequestQuoter((HttpServletRequest) request);
  HttpServletResponse httpResponse = (HttpServletResponse) response;

  String mime = inferMimeType(request);
  if (mime == null) {
    httpResponse.setContentType("text/plain; charset=utf-8");
  } else if (mime.startsWith("text/html")) {
    // HTML with unspecified encoding, we want to
    // force HTML with utf-8 encoding
    // This is to avoid the following security issue:
    // http://openmya.hacker.jp/hasegawa/security/utf7cs.html
    httpResponse.setContentType("text/html; charset=utf-8");
  } else if (mime.startsWith("application/xml")) {
    httpResponse.setContentType("text/xml; charset=utf-8");
  }
  chain.doFilter(quoted, httpResponse);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号