public Map<String,List<String>> toMultimap(boolean response){
  Map<String,List<String>> result=new TreeMap<String,List<String>>(FIELD_NAME_COMPARATOR);
  for (int i=0; i < namesAndValues.size(); i+=2) {
    String fieldName=namesAndValues.get(i);
    String value=namesAndValues.get(i + 1);
    List<String> allValues=new ArrayList<String>();
    List<String> otherValues=result.get(fieldName);
    if (otherValues != null) {
      allValues.addAll(otherValues);
    }
    allValues.add(value);
    result.put(fieldName,Collections.unmodifiableList(allValues));
  }
  if (response && statusLine != null) {
    result.put(null,Collections.unmodifiableList(Collections.singletonList(statusLine)));
  }
 else   if (requestLine != null) {
    result.put(null,Collections.unmodifiableList(Collections.singletonList(requestLine)));
  }
  return Collections.unmodifiableMap(result);
}

public Map < String , List < String > > toMultimap ( boolean response ) { Map < String , List < String > > result = new TreeMap < String , List < String > > ( FIELD_NAME_COMPARATOR ) ; for ( int i = 0 ; i < namesAndValues . size ( ) ; i += 2 ) { String fieldName = namesAndValues . get ( i ) ; String value = namesAndValues . get ( i + 1 ) ; List < String > allValues = new ArrayList < String > ( ) ; List < String > otherValues = result . get ( fieldName ) ; if ( otherValues != null ) { allValues . addAll ( otherValues ) ; } allValues . add ( value ) ; result . put ( fieldName , Collections . unmodifiableList ( allValues ) ) ; } if ( response && statusLine != null ) { result . put ( null , Collections . unmodifiableList ( Collections . singletonList ( statusLine ) ) ) ; } else if ( requestLine != null ) { result . put ( null , Collections . unmodifiableList ( Collections . singletonList ( requestLine ) ) ) ; } return Collections . unmodifiableMap ( result ) ; }
returns an immutable map containing each field to its list of values . the status line is mapped to null .
