Class ParameterizedHeaderValue
java.lang.Object
com.soklet.ParameterizedHeaderValue
Represents a single HTTP header field value that includes a name and may include semicolon-delimited parameters - encoding rules per RFC specifications are strictly enforced.
Many HTTP header field values are of the form:
name *( OWS ";" OWS parameter )where each
parameter is a name=value pair.
This class provides a small builder that makes it easy to construct parameterized header values using the formal HTTP grammar terms:
ParameterizedHeaderValue.Builder.tokenParameter(String, String)adds a parameter whose value is atoken(RFC 9110).ParameterizedHeaderValue.Builder.quotedParameter(String, String)adds a parameter whose value is aquoted-string(RFC 9110).ParameterizedHeaderValue.Builder.rfc8187Parameter(String, String)adds an extended parameter (name*=) whose value is anext-valueencoded per RFC 8187 (UTF-8, percent-encoded).
Example Content-Disposition header value:
String contentDisposition = ParameterizedHeaderValue.withName("attachment")
.quotedParameter("filename", "resume.pdf")
.rfc8187Parameter("filename", "résumé.pdf")
.stringValue();
// contentDisposition =>
// attachment; filename="resume.pdf"; filename*=UTF-8''r%C3%A9sum%C3%A9.pdf
The name must be ISO-8859-1 and must not contain the ';' parameter delimiter.
This class is immutable and thread-safe. The ParameterizedHeaderValue.Builder is not thread-safe.
- Author:
- Mark Allen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder used to construct instances ofParameterizedHeaderValueviawithName(String).static final classA single header-value parameter: given a header value likeattachment; filename="resume.pdf"; filename*=UTF-8''r%C3%A9sum%C3%A9.pdf, there are twofilenameparameter name-value pairs.static enumWhat type of header-value parameter this is:ParameterizedHeaderValue.ParameterType.TOKEN,ParameterizedHeaderValue.ParameterType.QUOTED, orParameterizedHeaderValue.ParameterType.RFC_8187. -
Method Summary
Modifier and TypeMethodDescriptionbooleangetName()Returns the name (non-parameter) portion of this header value.Returns the parameters (including their types and unencoded values) that make up this header value.Returns the HTTP wire format string for this header field value: the name followed by any semicolon-delimited parameters.inthashCode()toString()Returns a debug representation of this instance and its internal state.
-
Method Details
-
withName
-
getName
-
getStringValue
Returns the HTTP wire format string for this header field value: the name followed by any semicolon-delimited parameters.This is the official string form of
ParameterizedHeaderValue. No guarantees are made abouttoString().- Returns:
- the wire-format header field value
-
getParameters
Returns the parameters (including their types and unencoded values) that make up this header value.The returned list is immutable.
-
toString
-
equals
-
hashCode
-