Class DownloadHttpResponse
java.lang.Object
io.jenkins.plugins.interactiveinput.rest.DownloadHttpResponse
- All Implemented Interfaces:
org.kohsuke.stapler.HttpResponse
An
HttpResponse that streams a byte payload as a browser file download (Interactive View
download feature, item #1).
The binary counterpart of JsonHttpResponse. It always sets:
Content-Disposition: attachmentwith both an ASCII-sanitisedfilename="…"and an RFC 5987filename*=UTF-8''…, so a non-ASCII name still downloads correctly while the header itself can never be broken by a quote, backslash or CR/LF smuggled into the file name (header-injection defence);X-Content-Type-Options: nosniffso the browser never MIME-sniffs the bytes into something executable; andCache-Control: no-store(a review snapshot may change between versions).
The payload is prepared in memory by the caller. The interactiveView step caps a single
snapshot at 2 MB and a published group at 8 MB, so both a single-file download and a
whole-group ZIP stay comfortably bounded.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidgenerateResponse(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, Object node) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.kohsuke.stapler.HttpResponse
generateResponse
-
Constructor Details
-
DownloadHttpResponse
public DownloadHttpResponse(@NonNull String contentType, @NonNull String downloadName, @NonNull byte[] body) - Parameters:
contentType- the responseContent-Type(e.g.application/octet-streamfor a single file,application/zipfor a group archive)downloadName- the suggested file name (sanitised into the header bycontentDisposition(java.lang.String))body- the bytes to stream (copied defensively so the caller cannot mutate them later)
-
-
Method Details
-
generateResponse
public void generateResponse(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, Object node) throws IOException - Specified by:
generateResponsein interfaceorg.kohsuke.stapler.HttpResponse- Throws:
IOException
-