code: public void setContentType(String contentType) 
      {
          if (isCommitted())
              return;
          
          if (contentType==null)
          {
              _mimeType=null;
              _header.remove(HttpFields.__ContentType);
          }
          else
          {
              // Look for encoding in contentType
              int i0=contentType.indexOf(';');
              
              if (i0>0)
              {
                  // Strip params off mimetype
                  _mimeType=contentType.substring(0,i0).trim();
                  
                  // Look for charset
                  int i1=contentType.indexOf("charset=",i0);
                  if (i1>=0)
                  {
                      i1+=8;
                      int i2 = contentType.indexOf(' ',i1);
                      _characterEncoding = (0<i2)
                      ? contentType.substring(i1,i2)
                                      : contentType.substring(i1);
                      _characterEncoding = QuotedStringTokenizer.unquote(_characterEncoding);
                  }
                  else // No encoding in the params.
                  {
                      if (_characterEncoding!=null)
                          // Add any previously set encoding.
                          contentType+=";charset="+QuotedStringTokenizer.quote(_characterEncoding,";= ");
                  }
              }
              else // No encoding and no other params
              {
                  _mimeType=contentType;
                  // Add any previously set encoding.
                  if (_characterEncoding!=null)
                      contentType+=";charset="+QuotedStringTokenizer.quote(_characterEncoding,";= ");
              }
              
              _header.put(HttpFields.__ContentType,contentType);
          }
      }
docs: /* ------------------------------------------------------------