public void setCookieParams(TreeSet<HtmlParameter> cookieParams) {
        if (cookieParams.isEmpty()) {
            setHeader(HttpHeader.COOKIE, null);
        }

        StringBuilder sbData = new StringBuilder();

        for (HtmlParameter parameter : cookieParams) {
            if (parameter.getType() != HtmlParameter.Type.cookie) {
                continue;
            }

            String cookieName = parameter.getName();
            if (!cookieName.isEmpty()) {
                sbData.append(cookieName);
                sbData.append('=');
            }
            sbData.append(parameter.getValue());
            sbData.append("; ");
        }

        if (sbData.length() <= 2) {
            setHeader(HttpHeader.COOKIE, null);
            return;
        }

        final String data = sbData.substring(0, sbData.length() - 2);
        setHeader(HttpHeader.COOKIE, data);
    }
public void setCookieParams ( TreeSet < HtmlParameter > cookieParams ) { if ( cookieParams . isEmpty ( ) ) { setHeader ( HttpHeader . COOKIE , null ) ; } StringBuilder sbData = new StringBuilder ( ) ; for ( HtmlParameter parameter : cookieParams ) { if ( parameter . getType ( ) != HtmlParameter . Type . cookie ) { continue ; } String cookieName = parameter . getName ( ) ; if ( ! cookieName . isEmpty ( ) ) { sbData . append ( cookieName ) ; sbData . append ( '=' ) ; } sbData . append ( parameter . getValue ( ) ) ; sbData . append ( "; " ) ; } if ( sbData . length ( ) <= 2 ) { setHeader ( HttpHeader . COOKIE , null ) ; return ; } final String data = sbData . substring ( 0 , sbData . length ( ) - 2 ) ; setHeader ( HttpHeader . COOKIE , data ) ; }
based on cookieParams