public Map < String , String > createHeadersFromString ( String headersAndValues ) { if ( headersAndValues == null || headersAndValues . isEmpty ( ) ) return Collections . emptyMap ( ) ; final StringTokenizer token = new StringTokenizer ( headersAndValues , "@" ) ; final Map < String , String > theHeaders = new HashMap < String , String > ( token . countTokens ( ) ) ; while ( token . hasMoreTokens ( ) ) { final String headerAndValue = token . nextToken ( ) ; if ( ! headerAndValue . contains ( ":" ) ) throw new IllegalArgumentException ( "Request headers wrongly configured, missing separator :" + headersAndValues ) ; final String header = headerAndValue . substring ( 0 , headerAndValue . indexOf ( ":" ) ) ; final String value = headerAndValue . substring ( headerAndValue . indexOf ( ":" ) + 1 , headerAndValue . length ( ) ) ; theHeaders . put ( header , value ) ; } return theHeaders ; }
Create headers from a string .