Class DownloadHttpResponse

java.lang.Object
io.jenkins.plugins.interactiveinput.rest.DownloadHttpResponse
All Implemented Interfaces:
org.kohsuke.stapler.HttpResponse

public class DownloadHttpResponse extends Object implements 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: attachment with both an ASCII-sanitised filename="…" and an RFC 5987 filename*=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: nosniff so the browser never MIME-sniffs the bytes into something executable; and
  • Cache-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 Details

    • DownloadHttpResponse

      public DownloadHttpResponse(@NonNull String contentType, @NonNull String downloadName, @NonNull byte[] body)
      Parameters:
      contentType - the response Content-Type (e.g. application/octet-stream for a single file, application/zip for a group archive)
      downloadName - the suggested file name (sanitised into the header by contentDisposition(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:
      generateResponse in interface org.kohsuke.stapler.HttpResponse
      Throws:
      IOException