Module org.htmlunit

Class ContentDisposition

java.lang.Object
org.htmlunit.http.ContentDisposition

public final class ContentDisposition extends Object
The result of parsing a Content-Disposition header (RFC 6266, RFC 2183).

Parameter names are case-insensitive (stored lower case); if a parameter is defined more than once, the first one wins. The values are not sanitized.

Author:
Ronald Brill
See Also:
  • Method Details

    • getType

      public String getType()
      Returns the disposition type.
      Returns:
      the disposition type in lower case (e.g. attachment or inline); an empty string if the header has none
    • isAttachment

      public boolean isAttachment()
      Checks the disposition type.
      Returns:
      true if the type is attachment
    • isInline

      public boolean isInline()
      Checks the disposition type.
      Returns:
      true if the type is inline
    • getParameter

      public String getParameter(String name)
      Returns the value of a plain parameter.
      Parameters:
      name - the name of the parameter (case-insensitive), without a trailing *
      Returns:
      the value of the plain parameter (quotes and escapes resolved) or null; an empty string for a parameter without a value or with an empty value
    • getExtendedParameter

      public String getExtendedParameter(String name)
      Returns the decoded value of an extended parameter (RFC 8187).
      Parameters:
      name - the name of the parameter (case-insensitive), without the trailing *
      Returns:
      the decoded value of the extended parameter (name*, RFC 8187) or null if there is no such parameter or the value can not be decoded
    • getParameters

      public Map<String,String> getParameters()
      Returns all plain parameters.
      Returns:
      the plain parameters (lower case names, in header order); not modifiable
    • getFilename

      public String getFilename()
      Returns the file name suggested by the server.
      Returns:
      the file name; the extended parameter filename* wins over filename; null if there is none. The name is returned as sent by the server, so it is not safe to use it as file name without checking.