code: public final void addContentDispositionHeader(Context context, String pid, String dsID, String download, Date asOfDateTime, MIMETypedStream stream) throws Exception {
          String headerValue = null;
          String filename = null;
  
          // is downloading requested?
          if (download != null && download.equals("true")) {
              // generate an "attachment" content disposition header with the filename
              filename = getFilename(context, pid, dsID, asOfDateTime, stream.getMIMEType());
              headerValue= attachmentHeader(filename);
          } else {
              // is the content disposition header enabled in the case of not downloading?
              if (m_datastreamContentDispositionInlineEnabled.equals("true")) {
                  // it is... generate the header with "inline"
                  filename = getFilename(context, pid, dsID, asOfDateTime, stream.getMIMEType());
                  headerValue= inlineHeader(filename);
              }
          }
          // create content disposition header to add
          Property[] header = { new Property ("content-disposition", headerValue) };
          // add header to existing headers if present, or set this as the new header if not
          if (stream.header != null) {
              Property headers[] = new Property[stream.header.length + 1];
              System.arraycopy(stream.header, 0, headers, 0, stream.header.length);
              headers[headers.length - 1] = header[0];
              stream.header = headers;
          } else {
              stream.header = header;
          }
  
      }
docs: Add a content disposition header to a MIMETypedStream based on configuration preferences.
  Header by default specifies "inline"; if download=true then "attachment" is specified.
  
  @param context
  @param pid
  @param dsID
  @param download
  true if file is to be downloaded
  @param asOfDateTime
  @param stream
  @throws Exception