public HttpServerExchange setResponseCookie ( final Cookie cookie ) { if ( getConnection ( ) . getUndertowOptions ( ) . get ( UndertowOptions . ENABLE_RFC6265_COOKIE_VALIDATION , UndertowOptions . DEFAULT_ENABLE_RFC6265_COOKIE_VALIDATION ) ) { if ( cookie . getValue ( ) != null && ! cookie . getValue ( ) . isEmpty ( ) ) { Rfc6265CookieSupport . validateCookieValue ( cookie . getValue ( ) ) ; } if ( cookie . getPath ( ) != null && ! cookie . getPath ( ) . isEmpty ( ) ) { Rfc6265CookieSupport . validatePath ( cookie . getPath ( ) ) ; } if ( cookie . getDomain ( ) != null && ! cookie . getDomain ( ) . isEmpty ( ) ) { Rfc6265CookieSupport . validateDomain ( cookie . getDomain ( ) ) ; } } if ( responseCookies == null ) { responseCookies = new TreeMap <> ( ) ; //hashmap is slow to allocate in JDK7 } responseCookies . put ( cookie . getName ( ) , cookie ) ; return this ; }
Sets a response cookie