static void writeResponse(Configuration conf, Writer out, String format)
      throws IOException, BadFormatException {
    //redact the sensitive information from the configuration values
    Configuration hconf = new Configuration(conf);
    HiveConfUtil.stripConfigurations(hconf);
    if (FORMAT_JSON.equals(format)) {
      Configuration.dumpConfiguration(hconf, out);
    } else if (FORMAT_XML.equals(format)) {
      hconf.writeXml(out);
    } else {
      throw new BadFormatException("Bad format: " + format);
    }
  }
Guts of the servlet - extracted for easy testing.
common/src/java/org/apache/hive/http/ConfServlet.java