Class Cookies

  • public class Cookies
    extends Object
    Class that contains utility methods for dealing with cookies.
    Stuart Douglas, Andre Dietisheim, Richard Opalka
    • Method Detail

      • parseSetCookieHeader

        public static Cookie parseSetCookieHeader​(String headerValue)
        Parses a "Set-Cookie:" response header value into its cookie representation. The header value is parsed according to the syntax that's defined in RFC2109:
          set-cookie      =       "Set-Cookie:" cookies
           cookies         =       1#cookie
           cookie          =       NAME "=" VALUE *(";" cookie-av)
           NAME            =       attr
           VALUE           =       value
           cookie-av       =       "Comment" "=" value
                           |       "Domain" "=" value
                           |       "Max-Age" "=" value
                           |       "Path" "=" value
                           |       "Secure"
                           |       "Version" "=" 1*DIGIT
        headerValue - The header value
        The cookie
        See Also:
        Cookie, rfc2109
      • parseRequestCookies

        public static Map<String,​Cookie> parseRequestCookies​(int maxCookies,
                                                                   boolean allowEqualInValue,
                                                                   List<String> cookies)
        /** Parses the cookies from a list of "Cookie:" header values. The cookie header values are parsed according to RFC2109 that defines the following syntax:
         cookie          =  "Cookie:" cookie-version
                            1*((";" | ",") cookie-value)
         cookie-value    =  NAME "=" VALUE [";" path] [";" domain]
         cookie-version  =  "$Version" "=" value
         NAME            =  attr
         VALUE           =  value
         path            =  "$Path" "=" value
         domain          =  "$Domain" "=" value
        maxCookies - The maximum number of cookies. Used to prevent hash collision attacks
        allowEqualInValue - if true equal characters are allowed in cookie values
        cookies - The cookie values to parse
        A pared cookie map
        See Also:
        Cookie, rfc2109
      • parseRequestCookies

        public static void parseRequestCookies​(int maxCookies,
                                               boolean allowEqualInValue,
                                               List<String> cookies,
                                               Set<Cookie> parsedCookies)