private boolean scanHeaders()
    throws IOException
  {
    int ch = read();
    long length = 0;

    _headers.clear();
    while (ch > 0 && ch != '\n' && ch != '\r') {
      _line.clear();

      _line.append((char) ch);
      for (ch = read();
           ch >= 0 && ch != '\n' && ch != '\r';
           ch = read()) {
        _line.append((char) ch);

        if (_maxLength < length++)
          throw new IOException(L.l("header length {0} exceeded.", _maxLength));
      }

      if (ch == '\r') {
        if ((ch = read()) == '\n')
          ch = read();
      }
      else if (ch == '\n')
        ch = read();

      int i = 0;
      for (; i < _line.length() && _line.charAt(i) != ':'; i++) {
      }

      String key = null;
      String value = null;
      if (i < _line.length()) {
        key = _line.substring(0, i).trim().toLowerCase(Locale.ENGLISH);
        value = _line.substring(i + 1).trim();

        List<String> values = _headers.get(key);

        if (values == null) {
          values = new ArrayList<>();
        }

        values.add(value);

        _headers.put(key, values);
      }
    }

    if (ch == '\r') {
      if ((ch = read()) != '\n') {
        _peek[0] = (byte) ch;
        _peekOffset = 0;
        _peekLength = 1;
      }
    }

    return true;
  }
private boolean scanHeaders ( ) throws IOException { int ch = read ( ) ; long length = 0 ; _headers . clear ( ) ; while ( ch > 0 && ch != '\n' && ch != '\r' ) { _line . clear ( ) ; _line . append ( ( char ) ch ) ; for ( ch = read ( ) ; ch >= 0 && ch != '\n' && ch != '\r' ; ch = read ( ) ) { _line . append ( ( char ) ch ) ; if ( _maxLength < length ++ ) throw new IOException ( L . l ( "header length {0} exceeded." , _maxLength ) ) ; } if ( ch == '\r' ) { if ( ( ch = read ( ) ) == '\n' ) ch = read ( ) ; } else if ( ch == '\n' ) ch = read ( ) ; int i = 0 ; for ( ; i < _line . length ( ) && _line . charAt ( i ) != ':' ; i ++ ) { } String key = null ; String value = null ; if ( i < _line . length ( ) ) { key = _line . substring ( 0 , i ) . trim ( ) . toLowerCase ( Locale . ENGLISH ) ; value = _line . substring ( i + 1 ) . trim ( ) ; List < String > values = _headers . get ( key ) ; if ( values == null ) { values = new ArrayList < > ( ) ; } values . add ( value ) ; _headers . put ( key , values ) ; } } if ( ch == '\r' ) { if ( ( ch = read ( ) ) != '\n' ) { _peek [ 0 ] = ( byte ) ch ; _peekOffset = 0 ; _peekLength = 1 ; } } return true ; }
Scans the mime headers.  The mime headers are in standard mail/http
header format: "key: value".