Package com.linkedin.alpini.base.misc
Enum Class HeaderUtils
- All Implemented Interfaces:
Serializable
,Comparable<HeaderUtils>
,Constable
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringBuilder
appendHex
(StringBuilder sb, int c) static String
buildContentType
(String type, String subType, Collection<Map.Entry<String, String>> parameters) static String
static CharSequence
cleanHeaderValue
(CharSequence value) Checks to ensure that a provided header value may be used as-is or returns a new string which has been appropiately filtered.static CharSequence
cleanStatusMessage
(CharSequence value) Cleans the status message and if no cleanup is required, returns the same String object.static StringBuilder
escapeDelimiters
(StringBuilder buffer, CharSequence text) static String
formatDate
(Date date) static boolean
isProhibitedCharacter
(int c) Check if the character is prohibited in a HTTP header value.static boolean
isQuotableParam
(String value) From RFC1341, a quoted value may contain any character except control characters or '"'.static UUID
nameUUIDFromBytes
(byte[] name) Static factory to retrieve a type 4 (pseudo-random)UUID
based on the specified byte array after transformation with the Jenkins hash function.static HeaderUtils.ContentType
parseContentType
(String contentType) static UUID
Static factory to retrieve a type 4 (pseudo randomly generated) UUID.static CharSequence
sanitizeHeaderValue
(CharSequence value) Builds a new String, filtering out values and performing fixup to provide a value which may be set as a HTTP header value.static CharSequence
Builds a new String, filtering out non-ASCII characters which are likely to cause problems.static HeaderUtils
Returns the enum constant of this class with the specified name.static HeaderUtils[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
SINGLETON
-
-
Field Details
-
HTTP_DATE_FORMAT
- See Also:
-
HTTP_DATE_GMT_TIMEZONE
- See Also:
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
isQuotableParam
From RFC1341, a quoted value may contain any character except control characters or '"'. -
buildContentType
-
buildContentType
-
parseContentType
-
formatDate
-
sanitizeStatusMessage
Builds a new String, filtering out non-ASCII characters which are likely to cause problems.- Parameters:
value
- Status message.- Returns:
- filtered message.
-
cleanStatusMessage
Cleans the status message and if no cleanup is required, returns the same String object.- Parameters:
value
- Status message.- Returns:
- filtered message.
-
isProhibitedCharacter
public static boolean isProhibitedCharacter(int c) Check if the character is prohibited in a HTTP header value. -
appendHex
-
sanitizeHeaderValue
Builds a new String, filtering out values and performing fixup to provide a value which may be set as a HTTP header value. The implementation of this method is based upon the value validation code in Netty 3.7.1- Parameters:
value
- header value.- Returns:
- filtered value.
-
cleanHeaderValue
Checks to ensure that a provided header value may be used as-is or returns a new string which has been appropiately filtered. The implementation of this method is based upon the value validation code in Netty 3.7.1- Parameters:
value
- header value.- Returns:
- filtered value.
-
escapeDelimiters
-
randomWeakUUID
Static factory to retrieve a type 4 (pseudo randomly generated) UUID. TheUUID
is generated using a cryptographically weak pseudo random number generator - theThreadLocalRandom
generator.- Returns:
- A randomly generated
UUID
-
nameUUIDFromBytes
Static factory to retrieve a type 4 (pseudo-random)UUID
based on the specified byte array after transformation with the Jenkins hash function.- Parameters:
name
- A byte array to be used to construct aUUID
- Returns:
- A
UUID
generated from the specified array
-