Interface B2Headers
-
- All Known Implementing Classes:
B2HeadersImpl
public interface B2Headers
B2Headers represents the HTTP headers that come with a response from the server. It stores the values as they are *set* on it, without modifying or encoding them. Callers are expected to store values as they should be encoded in HTTP requests. Note that getValueOrNull() returns the stored value without percentDecoding. Note that some convenience methods do percentDecode the value. See the per-method documentation.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
AUTHORIZATION
static java.lang.String
CLIENT_UNAUTHORIZED_TO_READ
static java.lang.String
CONTENT_LENGTH
static java.lang.String
CONTENT_MD5
static java.lang.String
CONTENT_RANGE
static java.lang.String
CONTENT_SHA1
static java.lang.String
CONTENT_TYPE
static java.lang.String
CUSTOM_UPLOAD_TIMESTAMP
static java.lang.String
EXPECT
static java.lang.String
FILE_ID
static java.lang.String
FILE_INFO_PREFIX
static java.lang.String
FILE_LEGAL_HOLD
static java.lang.String
FILE_NAME
static java.lang.String
FILE_RETENTION_MODE
static java.lang.String
FILE_RETENTION_RETAIN_UNTIL_TIMESTAMP
static java.lang.String
HEX_DIGITS_AT_END
static java.lang.String
LARGE_FILE_SHA1
static java.lang.String
LARGE_FILE_SHA1_INFO_NAME
static java.lang.String
PART_NUMBER
static java.lang.String
RANGE
static java.lang.String
REPLICATION_STATUS
static java.lang.String
RETRY_AFTER
static java.lang.String
SERVER_SIDE_ENCRYPTION
static java.lang.String
SERVER_SIDE_ENCRYPTION_CUSTOMER_ALGORITHM
static java.lang.String
SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY
static java.lang.String
SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY_MD5
static java.lang.String
SRC_LAST_MODIFIED_MILLIS
static java.lang.String
SRC_LAST_MODIFIED_MILLIS_INFO_NAME
static java.lang.String
TEST_MODE
static java.lang.String
UPLOAD_TIMESTAMP
static java.lang.String
USER_AGENT
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default java.util.Map<java.lang.String,java.lang.String>
getB2FileInfo()
default java.util.List<java.lang.String>
getClientUnauthorizedToReadHeaderList()
default long
getContentLength()
default java.lang.String
getContentMd5OrNull()
default java.lang.String
getContentSha1EvenIfUnverifiedOrNull()
default java.lang.String
getContentSha1OrNull()
default java.lang.String
getContentType()
default java.lang.String
getFileLegalHoldOrNull()
default java.lang.String
getFileNameOrNull()
default java.lang.String
getFileRetentionModeOrNull()
default java.lang.Long
getFileRetentionRetainUntilTimestampOrNull()
default java.lang.String
getLargeFileSha1OrNull()
java.util.Collection<java.lang.String>
getNames()
default java.lang.String
getReplicationStatusOrNull()
default java.lang.String
getServerSideEncryptionOrNull()
default java.lang.Long
getSrcLastModifiedMillis()
default java.lang.String
getSseCustomerAlgorithmOrNull()
default java.lang.String
getSseCustomerKeyMd5OrNull()
default java.lang.Long
getUploadTimestampOrNull()
java.lang.String
getValueOrNull(java.lang.String name)
default boolean
hasContentRange()
default boolean
isClientUnauthorizedToReadFileRetention()
default boolean
isClientUnauthorizedToReadLegalHold()
-
-
-
Field Detail
-
FILE_ID
static final java.lang.String FILE_ID
- See Also:
- Constant Field Values
-
FILE_NAME
static final java.lang.String FILE_NAME
- See Also:
- Constant Field Values
-
CONTENT_SHA1
static final java.lang.String CONTENT_SHA1
- See Also:
- Constant Field Values
-
TEST_MODE
static final java.lang.String TEST_MODE
- See Also:
- Constant Field Values
-
PART_NUMBER
static final java.lang.String PART_NUMBER
- See Also:
- Constant Field Values
-
UPLOAD_TIMESTAMP
static final java.lang.String UPLOAD_TIMESTAMP
- See Also:
- Constant Field Values
-
FILE_INFO_PREFIX
static final java.lang.String FILE_INFO_PREFIX
- See Also:
- Constant Field Values
-
HEX_DIGITS_AT_END
static final java.lang.String HEX_DIGITS_AT_END
- See Also:
- Constant Field Values
-
SRC_LAST_MODIFIED_MILLIS_INFO_NAME
static final java.lang.String SRC_LAST_MODIFIED_MILLIS_INFO_NAME
- See Also:
- Constant Field Values
-
SRC_LAST_MODIFIED_MILLIS
static final java.lang.String SRC_LAST_MODIFIED_MILLIS
- See Also:
- Constant Field Values
-
LARGE_FILE_SHA1_INFO_NAME
static final java.lang.String LARGE_FILE_SHA1_INFO_NAME
- See Also:
- Constant Field Values
-
LARGE_FILE_SHA1
static final java.lang.String LARGE_FILE_SHA1
- See Also:
- Constant Field Values
-
AUTHORIZATION
static final java.lang.String AUTHORIZATION
- See Also:
- Constant Field Values
-
CONTENT_LENGTH
static final java.lang.String CONTENT_LENGTH
- See Also:
- Constant Field Values
-
CONTENT_MD5
static final java.lang.String CONTENT_MD5
- See Also:
- Constant Field Values
-
CONTENT_TYPE
static final java.lang.String CONTENT_TYPE
- See Also:
- Constant Field Values
-
RANGE
static final java.lang.String RANGE
- See Also:
- Constant Field Values
-
CONTENT_RANGE
static final java.lang.String CONTENT_RANGE
- See Also:
- Constant Field Values
-
RETRY_AFTER
static final java.lang.String RETRY_AFTER
- See Also:
- Constant Field Values
-
USER_AGENT
static final java.lang.String USER_AGENT
- See Also:
- Constant Field Values
-
EXPECT
static final java.lang.String EXPECT
- See Also:
- Constant Field Values
-
CLIENT_UNAUTHORIZED_TO_READ
static final java.lang.String CLIENT_UNAUTHORIZED_TO_READ
- See Also:
- Constant Field Values
-
FILE_RETENTION_MODE
static final java.lang.String FILE_RETENTION_MODE
- See Also:
- Constant Field Values
-
FILE_RETENTION_RETAIN_UNTIL_TIMESTAMP
static final java.lang.String FILE_RETENTION_RETAIN_UNTIL_TIMESTAMP
- See Also:
- Constant Field Values
-
FILE_LEGAL_HOLD
static final java.lang.String FILE_LEGAL_HOLD
- See Also:
- Constant Field Values
-
SERVER_SIDE_ENCRYPTION
static final java.lang.String SERVER_SIDE_ENCRYPTION
- See Also:
- Constant Field Values
-
SERVER_SIDE_ENCRYPTION_CUSTOMER_ALGORITHM
static final java.lang.String SERVER_SIDE_ENCRYPTION_CUSTOMER_ALGORITHM
- See Also:
- Constant Field Values
-
SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY
static final java.lang.String SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY
- See Also:
- Constant Field Values
-
SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY_MD5
static final java.lang.String SERVER_SIDE_ENCRYPTION_CUSTOMER_KEY_MD5
- See Also:
- Constant Field Values
-
REPLICATION_STATUS
static final java.lang.String REPLICATION_STATUS
- See Also:
- Constant Field Values
-
CUSTOM_UPLOAD_TIMESTAMP
static final java.lang.String CUSTOM_UPLOAD_TIMESTAMP
- See Also:
- Constant Field Values
-
-
Method Detail
-
getNames
java.util.Collection<java.lang.String> getNames()
- Returns:
- a collection with the names of all the headers in this object. never null.
-
getValueOrNull
java.lang.String getValueOrNull(java.lang.String name)
- Returns:
- the value for the given header name, or null if none.
-
getContentType
default java.lang.String getContentType()
- Returns:
- the value of the Content-Type header or B2ContentTypes.APPLICATION_OCTET if there isn't one.
- NOTE
- this returns APPLICATION_OCTET because that's how you should treat content with an undeclared type (unless you're willing to look at other headers or the URI, etc. if you're willing to do that you can use getValueOrNull() instead of this convenience method.)
-
getContentLength
default long getContentLength()
- Returns:
- the value of the Content-Length header as a long.
- Throws:
java.lang.IllegalStateException
- if there isn't a Content-Length header or it can't be parsed as a long.- NOTE
- We throw for unparseable values because this is a standard HTTP header and really, really should be valid.
-
getFileNameOrNull
default java.lang.String getFileNameOrNull()
- Returns:
- the value of the X-Bz-File-Name header (percentDecoded) or null if that header isn't present or can't be percentDecoded.
- NOTE
- We return null here because this is a completely optional, non-standard header and anyone could put any type of value in it at any time.
-
getUploadTimestampOrNull
default java.lang.Long getUploadTimestampOrNull()
- Returns:
- the value of the X-Bz-Upload-Timestamp header (parsed as a long) or null if that header isn't present or can't be parsed.
- NOTE
- We return null here because this is a completely optional, non-standard header and anyone could put any type of value in it at any time.
-
hasContentRange
default boolean hasContentRange()
- Returns:
- true iff there's a value for the Content-Range header
-
getContentSha1OrNull
default java.lang.String getContentSha1OrNull()
- Returns:
- the value of the X-Bz-Content-Sha1 header, or null if none.
- NOTE
- We return null here instead of throwing an exception since this is a completely optional, non-standard header.
-
getContentMd5OrNull
default java.lang.String getContentMd5OrNull()
- Returns:
- the value of the Content-MD5 header, or null if none.
- NOTE
- We return null here instead of throwing an exception since this is a an optional header in B2. Older files will not have it.
-
getContentSha1EvenIfUnverifiedOrNull
default java.lang.String getContentSha1EvenIfUnverifiedOrNull()
- Returns:
- the value of the X-Bz-Content-Sha1 header with 'unverified:' removed from the front, if any, or null if there's no X-Bz-Content-Sha1 header.
- NOTE
- We return null here instead of throwing an exception since this is a completely optional, non-standard header.
-
getLargeFileSha1OrNull
default java.lang.String getLargeFileSha1OrNull()
- Returns:
- the value of the X-Bz-Content-Sha1 header, or null if none.
- NOTE
- We return null here instead of throwing an exception since this is a completely optional, non-standard header.
-
getB2FileInfo
default java.util.Map<java.lang.String,java.lang.String> getB2FileInfo()
- Returns:
- a new map with the names and values provided as fileInfo when the file was uploaded.
- NOTE
- the map may be empty, but it will never be null.
-
getSrcLastModifiedMillis
default java.lang.Long getSrcLastModifiedMillis()
- Returns:
- the value of the 'src_last_modified_millis' fileInfo or null if none or if it can't be parsed as a long.
- NOTE
- We return null here because this is a completely optional, non-standard header and anyone could put any type of value in it at any time.
-
getClientUnauthorizedToReadHeaderList
default java.util.List<java.lang.String> getClientUnauthorizedToReadHeaderList()
- Returns:
- the list of headers, if any, included in the `X-Bz-Client-Unauthorized-To-Read` header. If no such header is present, then returns null.
- NOTE
- We return null here instead of throwing an exception since this is a completely optional, non-standard header.
-
isClientUnauthorizedToReadFileRetention
default boolean isClientUnauthorizedToReadFileRetention()
- Returns:
- true if the client does not have app key capabilities to read file retention, according to the 'X-Bz-Client-Unauthorized-To-Read' header
-
getFileRetentionModeOrNull
default java.lang.String getFileRetentionModeOrNull()
- Returns:
- the value of the `X-Bz-File-Retention-Mode` header, or null if none.
- NOTE
- We return null here instead of throwing an exception since this is a completely optional, non-standard header.
-
getFileRetentionRetainUntilTimestampOrNull
default java.lang.Long getFileRetentionRetainUntilTimestampOrNull()
- Returns:
- the value of the `X-Bz-File-Retain-Until-Timestamp` header, or null if none.
- NOTE
- We return null here because this is a completely optional, non-standard header and anyone could put any type of value in it at any time.
-
isClientUnauthorizedToReadLegalHold
default boolean isClientUnauthorizedToReadLegalHold()
- Returns:
- true if the client does not have app key capabilities to read legal hold, according to the 'X-Bz-Client-Unauthorized-To-Read' header
-
getFileLegalHoldOrNull
default java.lang.String getFileLegalHoldOrNull()
- Returns:
- the value of the `X-Bz-File-Legal-Hold` header, or null if none.
- NOTE
- We return null here instead of throwing an exception since this is a completely optional, non-standard header.
-
getServerSideEncryptionOrNull
default java.lang.String getServerSideEncryptionOrNull()
- Returns:
- the value of the `X-Bz-Server-Side-Encryption` header, or null if none.
- NOTE
- We return null here instead of throwing an exception since this is a completely optional, non-standard header.
-
getSseCustomerAlgorithmOrNull
default java.lang.String getSseCustomerAlgorithmOrNull()
- Returns:
- the value of the `X-Bz-Server-Side-Encryption-Customer-Algorithm` header, or null if none.
- NOTE
- We return null here instead of throwing an exception since this is a completely optional, non-standard header.
-
getSseCustomerKeyMd5OrNull
default java.lang.String getSseCustomerKeyMd5OrNull()
- Returns:
- the value of the `X-Bz-Server-Side-Encryption-Customer-Key-Md5` header, or null if none.
- NOTE
- We return null here instead of throwing an exception since this is a completely optional, non-standard header.
-
getReplicationStatusOrNull
default java.lang.String getReplicationStatusOrNull()
- Returns:
- the value of the 'X-Bz-Replication-Status' header, or null if none.
- NOTE
- We return null here instead of throwing an exception since this is a completely optional, non-standard header.
-
-