Class HeaderValueParser

java.lang.Object
org.apache.juneau.commons.http.HeaderValueParser

public final class HeaderValueParser extends Object
Lightweight parser for HTTP header values as defined by RFC 2616.

Parses comma-delimited header values into HeaderElement objects, where each element has a name and optional semicolon-delimited parameters.

For example, the header value "text/html;charset=UTF-8;q=0.9, text/json" is parsed into two elements: "text/html" with parameters "charset=UTF-8" and "q=0.9", and "text/json" with no parameters.

  • Constructor Details

  • Method Details

    • readElements

      public static HeaderElement[] readElements(String value)
      Parses an HTTP header value into an array of HeaderElement objects.

      Elements are separated by commas. Each element may have parameters separated by semicolons. Quoted strings are respected (commas and semicolons inside quotes are not treated as delimiters).

      Parameters:
      value - The header value to parse. May be null or empty.
      Returns:
      An array of parsed elements, never null.