forked from I2P_Developers/i2p.i2p
44 lines
1.5 KiB
Plaintext
44 lines
1.5 KiB
Plaintext
|
<%@page pageEncoding="UTF-8"%><%
|
||
|
/*
|
||
|
* USE CAUTION WHEN EDITING
|
||
|
* Trailing whitespace OR NEWLINE on the last line will cause
|
||
|
* IllegalStateExceptions !!!
|
||
|
*
|
||
|
* Do not tag this file for translation.
|
||
|
*/
|
||
|
net.i2p.I2PAppContext ctx = net.i2p.I2PAppContext.getGlobalContext();
|
||
|
java.io.File f = net.i2p.router.web.LogsHelper.wrapperLogFile(ctx);
|
||
|
long length = f.length();
|
||
|
if (length <= 0 || !f.isFile()) {
|
||
|
response.sendError(404, "Not Found");
|
||
|
} else {
|
||
|
response.setContentType("text/plain");
|
||
|
response.setHeader("X-Content-Type-Options", "nosniff");
|
||
|
response.setHeader("Content-Length", Long.toString(length));
|
||
|
response.setDateHeader("Expires", 0);
|
||
|
response.addHeader("Cache-Control", "no-store, max-age=0, no-cache, must-revalidate");
|
||
|
response.addHeader("Pragma", "no-cache");
|
||
|
java.io.InputStream in = null;
|
||
|
try {
|
||
|
in = new java.io.FileInputStream(f);
|
||
|
java.io.OutputStream bout = response.getOutputStream();
|
||
|
int read = 0;
|
||
|
byte buf[] = new byte[4*1024];
|
||
|
while ((read = in.read(buf)) != -1) {
|
||
|
bout.write(buf, 0, read);
|
||
|
}
|
||
|
} catch (java.io.IOException ioe) {
|
||
|
// prevent 'Committed' IllegalStateException from Jetty
|
||
|
if (!response.isCommitted()) {
|
||
|
response.sendError(403, ioe.toString());
|
||
|
} else {
|
||
|
// not an error, happens when the browser closes the stream
|
||
|
// Jetty doesn't log this
|
||
|
throw ioe;
|
||
|
}
|
||
|
} finally {
|
||
|
if (in != null)
|
||
|
try { in.close(); } catch (java.io.IOException ioe) {}
|
||
|
}
|
||
|
}
|
||
|
%>
|