DataRecordDownloadOptions { @Nullable public String getContentDispositionHeader() { if (Strings.isNullOrEmpty(contentDispositionHeader)) { if (!Strings.isNullOrEmpty(fileName)) { String dispositionType = this.dispositionType; if (Strings.isNullOrEmpty(dispositionType)) { dispositionType = DISPOSITION_TYPE_INLINE; } contentDispositionHeader = formatContentDispositionHeader(dispositionType, fileName, rfc8187Encode(fileName)); } else if (DISPOSITION_TYPE_ATTACHMENT.equals(this.dispositionType)) { contentDispositionHeader = DISPOSITION_TYPE_ATTACHMENT; } } return contentDispositionHeader; } private  DataRecordDownloadOptions(final String mediaType,
                                      final String characterEncoding,
                                      final String fileName,
                                      final String dispositionType,
                                      boolean domainOverrideIgnored); static DataRecordDownloadOptions fromBlobDownloadOptions(
            @NotNull BlobDownloadOptions downloadOptions); @Nullable String getContentTypeHeader(); @Nullable String getContentDispositionHeader(); @Nullable String getMediaType(); @Nullable String getCharacterEncoding(); @Nullable String getFileName(); @Nullable String getDispositionType(); boolean isDomainOverrideIgnored(); static DataRecordDownloadOptions DEFAULT; }
@Test public void testGetContentDisposition() { for (String fileName : Lists.newArrayList(FILE_NAME_IMAGE, FILE_NAME_TEXT)) { for (String dispositionType : Lists.newArrayList(DISPOSITION_TYPE_INLINE, DISPOSITION_TYPE_ATTACHMENT)) { verifyContentDispositionHeader( getOptions(null, null, fileName, dispositionType), getContentDispositionHeader(fileName, fileName.equals(FILE_NAME_IMAGE) ? ENCODED_FILE_NAME_IMAGE : ENCODED_FILE_NAME_TEXT, dispositionType) ); } } }
@Test public void testGetContentDispositionWithNoDispositionType() { verifyContentDispositionHeader( getOptions(null, null, FILE_NAME_IMAGE, null), getContentDispositionHeader(FILE_NAME_IMAGE, ENCODED_FILE_NAME_IMAGE, DISPOSITION_TYPE_INLINE) ); }