Add Date header
This commit is contained in:
@@ -71,14 +71,18 @@ public class PlantUmlServlet extends HttpServlet {
|
|||||||
PrintWriter writer = resp.getWriter();
|
PrintWriter writer = resp.getWriter();
|
||||||
writer.print("<html>");
|
writer.print("<html>");
|
||||||
writer.print("<head>");
|
writer.print("<head>");
|
||||||
writer.print("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />");
|
writer
|
||||||
|
.print("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />");
|
||||||
writer.print("<meta http-equiv=\"expires\" content=\"0\">");
|
writer.print("<meta http-equiv=\"expires\" content=\"0\">");
|
||||||
writer.print("<meta http-equiv=\"pragma\" content=\"no-cache\">");
|
writer.print("<meta http-equiv=\"pragma\" content=\"no-cache\">");
|
||||||
writer.print("<meta http-equiv=\"cache-control\" content=\"no-cache, must-revalidate\">");
|
writer
|
||||||
writer.print("<link rel=\"SHORTCUT ICON\" href=\"/plantuml/favicon.ico\">");
|
.print("<meta http-equiv=\"cache-control\" content=\"no-cache, must-revalidate\">");
|
||||||
|
writer
|
||||||
|
.print("<link rel=\"SHORTCUT ICON\" href=\"/plantuml/favicon.ico\">");
|
||||||
writer.print("</head>");
|
writer.print("</head>");
|
||||||
writer.print("<body>");
|
writer.print("<body>");
|
||||||
writer.print("<h1>PlantUMLServer</h1><p>This application provides a servlet which serves images createdby <a href=\"http://plantuml.sourceforge.net\">PlantUML</a>.</p>");
|
writer
|
||||||
|
.print("<h1>PlantUMLServer</h1><p>This application provides a servlet which serves images createdby <a href=\"http://plantuml.sourceforge.net\">PlantUML</a>.</p>");
|
||||||
|
|
||||||
String text = request.getParameter("text");
|
String text = request.getParameter("text");
|
||||||
String url = request.getParameter("url");
|
String url = request.getParameter("url");
|
||||||
@@ -93,7 +97,8 @@ public class PlantUmlServlet extends HttpServlet {
|
|||||||
}
|
}
|
||||||
text = transcoder.decode(url);
|
text = transcoder.decode(url);
|
||||||
}
|
}
|
||||||
writer.print("<form method=post action=\"/plantuml/uml/post\"><textarea name=\"text\" cols=\"120\" rows=\"10\">");
|
writer
|
||||||
|
.print("<form method=post action=\"/plantuml/uml/post\"><textarea name=\"text\" cols=\"120\" rows=\"10\">");
|
||||||
if (text != null) {
|
if (text != null) {
|
||||||
encode = transcoder.encode(text);
|
encode = transcoder.encode(text);
|
||||||
writer.print(text);
|
writer.print(text);
|
||||||
@@ -102,10 +107,12 @@ public class PlantUmlServlet extends HttpServlet {
|
|||||||
writer.print("<hr>");
|
writer.print("<hr>");
|
||||||
writer.print("You can enter here a previously generated URL:<p>");
|
writer.print("You can enter here a previously generated URL:<p>");
|
||||||
|
|
||||||
String host = "http://" + request.getServerName()+ ":" + request.getServerPort();
|
String host = "http://" + request.getServerName() + ":"
|
||||||
|
+ request.getServerPort();
|
||||||
String total = host + "/plantuml/uml/image/" + encode;
|
String total = host + "/plantuml/uml/image/" + encode;
|
||||||
|
|
||||||
writer.print("<form method=\"post\" action=\"/plantuml/uml/post\"><input name=\"url\" type=\"text\" size=\"150\" value=\""
|
writer
|
||||||
|
.print("<form method=\"post\" action=\"/plantuml/uml/post\"><input name=\"url\" type=\"text\" size=\"150\" value=\""
|
||||||
+ total + "\">");
|
+ total + "\">");
|
||||||
writer.print("<br><input type=\"submit\"></form>");
|
writer.print("<br><input type=\"submit\"></form>");
|
||||||
|
|
||||||
@@ -131,7 +138,6 @@ public class PlantUmlServlet extends HttpServlet {
|
|||||||
return TranscoderUtil.getDefaultTranscoder();
|
return TranscoderUtil.getDefaultTranscoder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void handleImage(HttpServletResponse response, String source)
|
private void handleImage(HttpServletResponse response, String source)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
source = URLDecoder.decode(source, "UTF-8");
|
source = URLDecoder.decode(source, "UTF-8");
|
||||||
@@ -173,8 +179,15 @@ public class PlantUmlServlet extends HttpServlet {
|
|||||||
SourceStringReader reader = new SourceStringReader(plantUmlSource
|
SourceStringReader reader = new SourceStringReader(plantUmlSource
|
||||||
.toString());
|
.toString());
|
||||||
// Write the first image to "os"
|
// Write the first image to "os"
|
||||||
|
long today = System.currentTimeMillis();
|
||||||
|
response.addDateHeader("Expires", today + 31536000000L);
|
||||||
|
// today + 1 year
|
||||||
|
response.addDateHeader("Last-Modified", 1261440000000L);
|
||||||
|
// 2009 dec 22 constant date in the past
|
||||||
|
response.addHeader("Cache-Control", "public");
|
||||||
response.setContentType("image/png");
|
response.setContentType("image/png");
|
||||||
reader.generateImage(response.getOutputStream());
|
reader.generateImage(response.getOutputStream());
|
||||||
|
|
||||||
response.flushBuffer();
|
response.flushBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user