Class ParameterizedHeaderValue

java.lang.Object
com.soklet.ParameterizedHeaderValue

@ThreadSafe public final class ParameterizedHeaderValue extends Object
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:

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