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.
    • 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.