private static Response join ( final Response response ) throws IOException { final StringBuilder cookies = new StringBuilder ( ) ; for ( final String header : response . head ( ) ) { final Matcher matcher = TkJoinedCookies . PTN . matcher ( header ) ; if ( ! matcher . matches ( ) ) { continue ; } cookies . append ( matcher . group ( 1 ) ) . append ( ", " ) ; } final Response out ; if ( cookies . length ( ) > 0 ) { out = new RsWithHeader ( new RsWithoutHeader ( response , "Set-cookie" ) , "Set-Cookie" , cookies . toString ( ) ) ; } else { out = response ; } return out ; }
Join them .