private static Header [ ] removeHeaders ( Header [ ] headersToClean , String [ ] headersToRemove ) { ArrayList < Header > headers = new ArrayList <> ( ) ; if ( headersToClean == null ) { return null ; } for ( Header header : headersToClean ) { if ( ! StringUtils . equalsAnyIgnoreCase ( header . getName ( ) , headersToRemove ) ) { headers . add ( header ) ; } } LOG . debug ( "Removed the content-length and content-type headers as the HTTP Client lib will care " + "about them as soon as the entity is set on the POST object." ) ; Header [ ] headersArray = new Header [ headers . size ( ) ] ; headersArray = headers . toArray ( headersArray ) ; return headersArray ; }
Remove headers form header array that match Strings in headersToRemove