public void doIndex( StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { URLConnection con = connect(); // since we end up redirecting users to jnlpJars/foo.jar/, set the content disposition // so that browsers can download them in the right file name. // see http://support.microsoft.com/kb/260519 and http://www.boutell.com/newfaq/creating/forcedownload.html rsp.setHeader("Content-Disposition", "attachment; filename=" + fileName); InputStream in = con.getInputStream(); rsp.serveFile(req, in, con.getLastModified(), con.getContentLength(), "*.jar" ); in.close(); }
@WebMethod(name="script.js") public void doScriptJs(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { rsp.serveFile(req, hasResource("/script.js"), TimeUnit.DAYS.toMillis(1)); }
@WebMethod(name="style.css") public void doStyleCss(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { rsp.serveFile(req, hasResource("/style.css"), TimeUnit.DAYS.toMillis(1)); }
/** * Serves the JavaScript file associated with this console annotator factory. */ @WebMethod(name="script.js") public void doScriptJs(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { rsp.serveFile(req, getResource("/script.js"), TimeUnit.DAYS.toMillis(1)); }
@WebMethod(name="style.css") public void doStyleCss(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { rsp.serveFile(req, getResource("/style.css"), TimeUnit.DAYS.toMillis(1)); }
/** * Serves static resources placed along with Jelly view files. * <p> * This method can serve a lot of files, so care needs to be taken * to make this method secure. It's not clear to me what's the best * strategy here, though the current implementation is based on * file extensions. */ public void doResources(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { String path = req.getRestOfPath(); // cut off the "..." portion of /resources/.../path/to/file // as this is only used to make path unique (which in turn // allows us to set a long expiration date path = path.substring(path.indexOf('/',1)+1); int idx = path.lastIndexOf('.'); String extension = path.substring(idx+1); if(ALLOWED_RESOURCE_EXTENSIONS.contains(extension)) { URL url = pluginManager.uberClassLoader.getResource(path); if(url!=null) { long expires = MetaClass.NO_CACHE ? 0 : 365L * 24 * 60 * 60 * 1000; /*1 year*/ rsp.serveFile(req,url,expires); return; } } rsp.sendError(HttpServletResponse.SC_NOT_FOUND); }
/** {@inheritDoc} */ @Override public void serveFile(StaplerRequest req, URL resource, long expiration) throws ServletException, IOException { getWrapped().serveFile(req, resource, expiration); }
/** {@inheritDoc} */ @Override public void serveFile(StaplerRequest req, InputStream data, long lastModified, long expiration, int contentLength, String fileName) throws ServletException, IOException { getWrapped().serveFile(req, data, lastModified, expiration, contentLength, fileName); }
/** {@inheritDoc} */ @Override public void serveFile(StaplerRequest req, InputStream data, long lastModified, long contentLength, String fileName) throws ServletException, IOException { getWrapped().serveFile(req, data, lastModified, contentLength, fileName); }
public void doBuildScript(final StaplerRequest req, final StaplerResponse rsp) throws ServletException, IOException { final InputStream file = new ByteArrayInputStream(getScript().getBytes(StandardCharsets.UTF_8)); rsp.serveFile(req, file, new Date().getTime(), 0, -1L, "dotci.sh"); }
/** {@inheritDoc} */ @Override public void serveFile(StaplerRequest req, InputStream data, long lastModified, long contentLength, String fileName) throws ServletException, IOException { getWrapped().serveFile(req, data, lastModified, contentLength, fileName); }
public void doIndex(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { URLConnection con = connect(); // since we end up redirecting users to jnlpJars/foo.jar/, set the content disposition // so that browsers can download them in the right file name. // see http://support.microsoft.com/kb/260519 and http://www.boutell.com/newfaq/creating/forcedownload.html rsp.setHeader("Content-Disposition", "attachment; filename=" + fileName); InputStream in = con.getInputStream(); rsp.serveFile(req, in, con.getLastModified(), con.getContentLength(), "*.jar"); in.close(); }
public void doIndex( StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { URLConnection con = connect(); // since we end up redirecting users to jnlpJars/foo.jar/, set the content disposition // so that browsers can download them in the right file name. // see http://support.microsoft.com/kb/260519 and http://www.boutell.com/newfaq/creating/forcedownload.html rsp.setHeader("Content-Disposition", "attachment; filename=" + fileName); InputStream in = con.getInputStream(); rsp.serveFile(req, in, con.getLastModified(), con.getContentLength(), "*.jar" ); in.close(); }
public void doIndex( StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { URLConnection con = connect(); // since we end up redirecting users to jnlpJars/foo.jar/, set the content disposition // so that browsers can download them in the right file name. // see http://support.microsoft.com/kb/260519 and http://www.boutell.com/newfaq/creating/forcedownload.html rsp.setHeader("Content-Disposition", "attachment; filename=" + fileName); InputStream in = con.getInputStream(); rsp.serveFile(req, in, con.getLastModified(), con.getContentLength(), "*.jar" ); in.close(); }
public void doIndex( StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { URLConnection con = connect(); //rsp.setHeader("Content-Disposition", "attachment; filename=" + file.getAbsolutePath()); rsp.setHeader("Content-Disposition", "attachment; filename=" + file.getName()); InputStream in = con.getInputStream(); rsp.serveFile(req, in, con.getLastModified(), con.getContentLength(), file.getName()); in.close(); //The file has been read; the request will not be repeated this.close(); }
/** * Serves the JavaScript file associated with this console annotator factory. */ @WebMethod(name="script.js") public void doScriptJs(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { rsp.serveFile(req, getResource("/script.js"), TimeUnit2.DAYS.toMillis(1)); }
/** * Serves the JavaScript file associated with this console annotator * factory. */ @WebMethod(name = "script.js") public void doScriptJs(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { rsp.serveFile(req, getResource("/script.js"), TimeUnit2.DAYS.toMillis(1)); }
@WebMethod(name="script.js") public void doScriptJs(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { rsp.serveFile(req, hasResource("/script.js"), TimeUnit2.DAYS.toMillis(1)); }