public List < HeaderEntry > getHeaderEntryList ( ) { final List < HeaderEntry > list = new ArrayList <> ( ) ; final Iterator it = this . headers . entrySet ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { final Map . Entry pair = ( Map . Entry ) it . next ( ) ; System . out . println ( pair . getKey ( ) + " = " + pair . getValue ( ) ) ; final HeaderEntry e = HeaderEntry . newBuilder ( ) . setKey ( ( String ) pair . getKey ( ) ) . setValue ( ( String ) pair . getValue ( ) ) . build ( ) ; list . add ( e ) ; it . remove ( ) ; // avoids a ConcurrentModificationException } return list ; }
get http header as a list of HeaderEntry .