private void appendHeaders ( OutputStream outputStream , InternetHeaders internetHeaders ) { try { // Headers @ SuppressWarnings ( "unchecked" ) Enumeration < Header > headers = internetHeaders . getAllHeaders ( ) ; while ( headers . hasMoreElements ( ) ) { Header header = headers . nextElement ( ) ; String headerLine = String . format ( "%s: %s\r\n" , header . getName ( ) , header . getValue ( ) ) ; outputStream . write ( headerLine . getBytes ( "UTF-8" ) ) ; } // Empty line outputStream . write ( "\r\n" . getBytes ( "UTF-8" ) ) ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( e ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } }
Append headers .