Skip to content

Commit 62d9a99

Browse files
committed
delete redundant code
1 parent e8f5f84 commit 62d9a99

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/main/java/com/hunantv/fw/Dispatcher.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class Dispatcher extends AbstractHandler {
2121

2222
public final static FwLogger logger = new FwLogger(Dispatcher.class);
2323
Application app = Application.getInstance();
24-
protected Routes routes = app.getRoutes();;
24+
protected Routes routes = app.getRoutes();
2525
protected boolean debug = app.isDebug();
2626

2727
protected static final MultipartConfigElement MULTI_PART_CONFIG = new MultipartConfigElement(System.getProperty("java.io.tmpdir"));
@@ -32,7 +32,9 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques
3232
Long btime = System.currentTimeMillis();
3333
logger.initSeqid();
3434
logger.debug(target);
35-
response.setContentType("text/html;charset=UTF-8");
35+
if (WebUtil.isTextHtml(request)) {
36+
response.setContentType("text/html;charset=UTF-8");
37+
}
3638
if (WebUtil.isMultipart(request)) {
3739
request.setAttribute(Request.__MULTIPART_CONFIG_ELEMENT, MULTI_PART_CONFIG);
3840
}
@@ -47,7 +49,7 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques
4749
this.err500(response, ex);
4850
} finally {
4951
Long etime = System.currentTimeMillis();
50-
logger.delayInfo("cost", new Long(etime - btime).toString());
52+
logger.delayInfo("cost", Long.toString(etime - btime));
5153
logger.clearSeqid();
5254
}
5355
}

src/main/java/com/hunantv/fw/utils/WebUtil.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ public static boolean isMultipart(HttpServletRequest request) {
88
String contentType = request.getContentType();
99
return contentType != null && contentType.startsWith("multipart/form-data");
1010
}
11-
11+
public static boolean isTextHtml(HttpServletRequest request) {
12+
String HeaderValue = request.getHeader("Accept");
13+
return HeaderValue != null && HeaderValue.startsWith("text/html");
14+
}
1215
private static String[] IP_HEADS = new String[] {
1316
"X-Forwarded-For",
1417
"Proxy-Client-IP",

0 commit comments

Comments
 (0)