static void writeResponse(Configuration conf, Writer out, String format)
    throws IOException, BadFormatException {
    Configuration maskedConf = mask(conf);
    if (FORMAT_JSON.equals(format)) {
      Configuration.dumpConfiguration(maskedConf, out);
    } else if (FORMAT_XML.equals(format)) {
      maskedConf.writeXml(out);
    } else {
      throw new BadFormatException("Bad format: " + format);
    }
  }
Guts of the servlet - extracted for easy testing.
hbase-http/src/main/java/org/apache/hadoop/hbase/http/conf/ConfServlet.java