Class IfRange

All Implemented Interfaces:
Serializable, Cloneable, Header, NameValuePair

@Header("If-Range") public class IfRange extends BasicDateHeader
Represents a parsed If-Range HTTP request header.

If the entity is unchanged, send me the part(s) that I am missing; otherwise, send me the entire new entity.

Example

If-Range: "737060cd8c284d8af7ad3082f209582d"

RFC2616 Specification
If a client has a partial copy of an entity in its cache, and wishes to have an up-to-date copy of the entire entity in its cache, it could use the Range request-header with a conditional GET (using either or both of If-Unmodified-Since and If-Match.) However, if the condition fails because the entity has been modified, the client would then have to make a second request to obtain the entire current entity-body.

The If-Range header allows a client to "short-circuit" the second request. Informally, its meaning is `if the entity is unchanged, send me the part(s) that I am missing; otherwise, send me the entire new entity'.

If-Range = "If-Range" ":" ( entity-tag | HTTP-date )

If the client has no entity tag for an entity, but does have a Last- Modified date, it MAY use that date in an If-Range header. (The server can distinguish between a valid HTTP-date and any form of entity-tag by examining no more than two characters.) The If-Range header SHOULD only be used together with a Range header, and MUST be ignored if the request does not include a Range header, or if the server does not support the sub-range operation.

If the entity tag given in the If-Range header matches the current entity tag for the entity, then the server SHOULD provide the specified sub-range of the entity using a 206 (Partial content) response. If the entity tag does not match, then the server SHOULD return the entire entity using a 200 (OK) response.

See Also:
  • Constructor Details

    • IfRange

      public IfRange(String value)
      Constructor.
      Parameters:
      value - The header value.
      Must be an RFC-1123 formated string (e.g. "Sat, 29 Oct 1994 19:43:31 GMT").
      Can be null.
    • IfRange

      public IfRange(ZonedDateTime value)
      Constructor.
      Parameters:
      value - The header value.
      Can be null.
    • IfRange

      public IfRange(EntityTag value)
      Constructor.
      Parameters:
      value - The header value.
      Can be null.
    • IfRange

      public IfRange(Supplier<?> value)
      Constructor with delayed value.

      Header value is re-evaluated on each call to getValue().

      Parameters:
      value - The supplier of the header value.
      Supplier must supply either EntityTag or ZonedDateTime objects.
      Can be null.
  • Method Details

    • of

      public static IfRange of(String value)
      Static creator.
      Parameters:
      value - The header value.
      Must be an RFC-1123 formated string (e.g. "Sat, 29 Oct 1994 19:43:31 GMT").
      Can be null.
      Returns:
      A new header bean, or null if the name is null or empty or the value is null.
    • of

      public static IfRange of(ZonedDateTime value)
      Static creator.
      Parameters:
      value - The header value.
      Can be null.
      Returns:
      A new header bean, or null if the name is null or empty or the value is null.
    • of

      public static IfRange of(EntityTag value)
      Static creator.
      Parameters:
      value - The header value.
      Can be null.
      Returns:
      A new header bean, or null if the name is null or empty or the value is null.
    • of

      public static IfRange of(Supplier<?> value)
      Static creator with delayed value.

      Header value is re-evaluated on each call to getValue().

      Parameters:
      value - The supplier of the header value.
      Supplier must supply either EntityTag or ZonedDateTime objects.
      Can be null.
      Returns:
      A new header bean, or null if the name is null or empty or the value is null.
    • getValue

      public String getValue()
      Specified by:
      getValue in interface NameValuePair
      Overrides:
      getValue in class BasicDateHeader
    • asEntityTag

      Returns this header as an EntityTag.
      Returns:
      This header as an EntityTag.