Class ContentDisposition

All Implemented Interfaces:
Serializable, Header, NameValuePair

@Header("Content-Disposition") public class ContentDisposition extends BasicStringRangesHeader
Represents a parsed Content-Disposition HTTP request header.

In a regular HTTP response, the Content-Disposition response header is a header indicating if the content is expected to be displayed inline in the browser, that is, as a Web page or as part of a Web page, or as an attachment, that is downloaded and saved locally.

Example

Content-Disposition: form-data; name="fieldName"; filename="filename.jpg"

RFC2616 Specification
The Expect request-header field is used to indicate that particular server behaviors are required by the client.

content-disposition = "Content-Disposition" ":" disposition-type *( ";" disposition-parm ) disposition-type = "attachment" | disp-extension-token disposition-parm = filename-parm | disp-extension-parm filename-parm = "filename" "=" quoted-string disp-extension-token = token disp-extension-parm = token "=" ( token | quoted-string )

See Also:
  • Constructor Details

  • Method Details

    • attachment

      public static ContentDisposition attachment(String filename)
      Creates a Content-Disposition header for a response attachment (browser download / save-as).

      Produces attachment; filename="..." with the filename escaped for use inside an HTTP quoted-string (\ and " backslash-escaped). CR and LF are rejected to reduce response-splitting risk.

      For non-ASCII filenames, RFC 5987 filename* is not set; callers needing full Unicode support may build a header value manually or extend this API later.

      Parameters:
      filename - Suggested download name. Must not be null, blank, or contain CR/LF.
      Returns:
      A non-null header.
      Throws:
      IllegalArgumentException - If filename is null, blank, or contains line breaks.
    • of

      public static ContentDisposition of(String value)
      Static creator.
      Parameters:
      value - The header value.
      Must be parsable by StringRanges.of(String).
      Can be null.
      Returns:
      A new header bean, or null if the value is null.
    • of

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

      public static ContentDisposition of(Supplier<StringRanges> value)
      Static creator with delayed value.

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

      Parameters:
      value - The supplier of the header value.
      Can be null.
      Returns:
      A new header bean, or null if the value is null.