Package com.composum.sling.core.util
Class HttpUtil
- java.lang.Object
-
- org.apache.sling.api.servlets.HttpConstants
-
- com.composum.sling.core.util.HttpUtil
-
public class HttpUtil extends org.apache.sling.api.servlets.HttpConstants
A basic class for all '/bin/{service}/path/to/resource' servlets.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
HttpUtil.CachableInstance
static interface
HttpUtil.InstanceFactory<Type extends HttpUtil.CachableInstance>
-
Field Summary
Fields Modifier and Type Field Description static String
HEADER_ACCEPT_ENCODING
static String
HEADER_CACHE_CONTROL
static String
HEADER_CONTENT_ENCODING
static String
HEADER_CONTENT_LENGTH
static String
HEADER_IF_NONE_MATCH
static String
HEADER_LOCATION
static String
HEADER_VARY
static String
VALUE_NO_CACHE
-
Constructor Summary
Constructors Constructor Description HttpUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <Type extends HttpUtil.CachableInstance>
TypegetInstance(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull String attributeKey, @NotNull HttpUtil.InstanceFactory<Type> factory)
static boolean
isModifiedSince(long ifModifiedSince, Long lastModified)
Deprecated.please usenotModifiedSince(long, Long)
since that's cleaner; this will be removed soonstatic boolean
isModifiedSince(long ifModifiedSince, Calendar lastModified)
Deprecated.please usenotModifiedSince(long, Calendar)
since that's cleaner; this will be removed soonstatic boolean
notModifiedSince(long ifModifiedSince, Long lastModified)
Checks whether we can skip transmission of a resource because of a recent enoughHttpConstants.HEADER_IF_MODIFIED_SINCE
header.static boolean
notModifiedSince(long ifModifiedSince, Calendar lastModified)
Checks whether we can skip transmission of a resource because of a recent enoughHttpConstants.HEADER_IF_MODIFIED_SINCE
header.
-
-
-
Field Detail
-
HEADER_LOCATION
public static final String HEADER_LOCATION
- See Also:
- Constant Field Values
-
HEADER_CACHE_CONTROL
public static final String HEADER_CACHE_CONTROL
- See Also:
- Constant Field Values
-
VALUE_NO_CACHE
public static final String VALUE_NO_CACHE
- See Also:
- Constant Field Values
-
HEADER_CONTENT_ENCODING
public static final String HEADER_CONTENT_ENCODING
- See Also:
- Constant Field Values
-
HEADER_CONTENT_LENGTH
public static final String HEADER_CONTENT_LENGTH
- See Also:
- Constant Field Values
-
HEADER_VARY
public static final String HEADER_VARY
- See Also:
- Constant Field Values
-
HEADER_ACCEPT_ENCODING
public static final String HEADER_ACCEPT_ENCODING
- See Also:
- Constant Field Values
-
HEADER_IF_NONE_MATCH
public static final String HEADER_IF_NONE_MATCH
- See Also:
- Constant Field Values
-
-
Method Detail
-
notModifiedSince
public static boolean notModifiedSince(long ifModifiedSince, Calendar lastModified)
Checks whether we can skip transmission of a resource because of a recent enoughHttpConstants.HEADER_IF_MODIFIED_SINCE
header. Returns true if the given lastModified date is after the {ifModifiedSince} or if there is no lastModified date, so that we don't know and have to transmit the resource, anyway.- Parameters:
ifModifiedSince
- value of theHttpConstants.HEADER_IF_MODIFIED_SINCE
headerlastModified
- date of the resource to be submitted- Returns:
- if the resource transmission can be skipped since the browser has the current version
-
notModifiedSince
public static boolean notModifiedSince(long ifModifiedSince, Long lastModified)
Checks whether we can skip transmission of a resource because of a recent enoughHttpConstants.HEADER_IF_MODIFIED_SINCE
header. Returns true if the given lastModified date is after the {ifModifiedSince} or if there is no lastModified date, so that we don't know and have to transmit the resource, anyway.- Parameters:
ifModifiedSince
- value of theHttpConstants.HEADER_IF_MODIFIED_SINCE
headerlastModified
- date of the resource to be submitted- Returns:
- if the resource transmission can be skipped since the browser has the current version
-
isModifiedSince
@Deprecated public static boolean isModifiedSince(long ifModifiedSince, Calendar lastModified)
Deprecated.please usenotModifiedSince(long, Calendar)
since that's cleaner; this will be removed soon
-
isModifiedSince
@Deprecated public static boolean isModifiedSince(long ifModifiedSince, Long lastModified)
Deprecated.please usenotModifiedSince(long, Long)
since that's cleaner; this will be removed soon
-
getInstance
@NotNull public static <Type extends HttpUtil.CachableInstance> Type getInstance(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull String attributeKey, @NotNull @NotNull HttpUtil.InstanceFactory<Type> factory)
-
-