Class HttpHeaderParser

java.lang.Object
com.google.appengine.tools.util.HttpHeaderParser

public class HttpHeaderParser extends Object
A collection of routines for parsing HTTP headers.
  • Constructor Details

    • HttpHeaderParser

      public HttpHeaderParser(String header)
      Create a parser.
      Parameters:
      header - header string, never null.
  • Method Details

    • isEnd

      public boolean isEnd()
      Are we at the end of the header?
      Returns:
      true if the header ended, false if one or more characters remain.
    • peek

      public int peek()
      Get next character without removing it.
      Returns:
      next character, or -1 if end of input.
    • eatChar

      public void eatChar(char ch) throws HttpHeaderParseException
      Eat a given character.
      Parameters:
      ch - character to expect.
      Throws:
      HttpHeaderParseException - if input does not start with ch.
    • eatLWS

      public void eatLWS()
      Eat linear white space (zero or more characters).
    • eatToken

      public String eatToken() throws HttpHeaderParseException
      Eat a token.
      Returns:
      token text, at least one character.
      Throws:
      HttpHeaderParseException - if input does not start with a token.
    • eatQuotedString

      public String eatQuotedString() throws HttpHeaderParseException
      Eat a quoted string.
      Returns:
      value read, can be empty.
      Throws:
      HttpHeaderParseException - if input does not start with a qstring.
    • eatTokenOrQuotedString

      public String eatTokenOrQuotedString() throws HttpHeaderParseException
      Eat a token or a quoted string.
      Returns:
      value read, can be empty.
      Throws:
      HttpHeaderParseException - if input does not start with either.
    • eatV0CookieToken

      public String eatV0CookieToken() throws HttpHeaderParseException
      Eat a Netscape V0 cookie token.
      Returns:
      a token, of length at least one.
      Throws:
      HttpHeaderParseException - if input does not start with a V0 tok.
    • eatV0CookieValue

      public String eatV0CookieValue()
      Eat a Netscape V0 cookie value.
      Returns:
      a value, can be empty.
    • eatV0CookieDate

      public Date eatV0CookieDate() throws HttpHeaderParseException
      Eat a Netscape V0 cookie date.
      Returns:
      date, never null.
      Throws:
      HttpHeaderParseException - if input does not start with a date.
    • makeAttributeValuePair

      public static StringBuffer makeAttributeValuePair(String attribute, String value)
      HTTP-encode an attribute=value pair.
      Parameters:
      attribute - the attribute, must be an HTTP token.
      value - attribute value, must not contain CR or LF.
      Returns:
      properly encoded attribute=value pair.
      Throws:
      IllegalArgumentException - if either argument is illegal.
    • getContentCharset

      public static String getContentCharset(String contentType) throws HttpHeaderParseException
      Get a charset from content type.
      Parameters:
      contentType - Content-Type header value.
      Returns:
      charset, or null if not present.
      Throws:
      HttpHeaderParseException - if contentType is misformatted.