private static String getHeaderParam ( final String value , final String paramName ) { if ( value == null || value . length ( ) == 0 ) return null ; final int length = value . length ( ) ; int start = value . indexOf ( ' ' ) + 1 ; if ( start == 0 || start == length ) return null ; int end = value . indexOf ( ' ' , start ) ; if ( end == - 1 ) end = length ; while ( start < end ) { int nameEnd = value . indexOf ( ' ' , start ) ; if ( nameEnd != - 1 && nameEnd < end && paramName . equals ( value . substring ( start , nameEnd ) . trim ( ) ) ) { String paramValue = value . substring ( nameEnd + 1 , end ) . trim ( ) ; int valueLength = paramValue . length ( ) ; if ( valueLength != 0 ) if ( valueLength > 2 && ' ' == paramValue . charAt ( 0 ) && ' ' == paramValue . charAt ( valueLength - 1 ) ) return paramValue . substring ( 1 , valueLength - 1 ) ; else return paramValue ; } start = end + 1 ; end = value . indexOf ( ' ' , start ) ; if ( end == - 1 ) end = length ; } return null ; }
Get parameter value from header value