/**
 * @license
 * Copyright 2017 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */

package foam.nanos.http;

import foam.core.*;
import java.io.PrintWriter;
import java.util.Enumeration;
import javax.servlet.http.HttpServletRequest;

public class TraceWebAgent
  implements WebAgent
{
  public TraceWebAgent() {}

  public void execute(X x) {
    try {
    PrintWriter        out = (PrintWriter)        x.get(PrintWriter.class);
    HttpServletRequest req = (HttpServletRequest) x.get(HttpServletRequest.class);

    out.println("<HTML>\n" +
        "<HEAD><TITLE>trace</TITLE></HEAD>\n" +
        "<BODY BGCOLOR=\"#FDF5E6\">\n" +
//        "<H1 ALIGN=\"CENTER\">trace</H1>\n" +
//        "<B>Request Method: </B>" +
//        req.getMethod() + "<BR>\n" +
//        "<B>Request URI: </B>" +
//        req.getRequestURI() + "<BR>\n" +
//        "<B>Request Protocol: </B>" +
//        req.getProtocol() + "<BR><BR>\n" +
        "<TABLE BORDER=1 ALIGN=\"CENTER\">\n" +
        "<TR BGCOLOR=\"#FFAD00\">\n" +
        "<TH>Header Name<TH>Header Value");
        Enumeration headerNames = req.getHeaderNames();
        while ( headerNames.hasMoreElements() ) {
          String headerName = (String) headerNames.nextElement();
          System.err.println("Header: " + headerName);
          out.println("<TR><TD>" + headerName);
          out.println("    <TD>" + req.getHeader(headerName));
        }
        out.println("</TABLE>\n</BODY></HTML>");
      } catch (Throwable t) {
          t.printStackTrace();
        }
  }
}

@@ -661,26 +661,24 @@
 5E6%5C%22%3E%5Cn%22 +%0A
-//
         %22%3CH1
@@ -707,26 +707,24 @@
 e%3C/H1%3E%5Cn%22 +%0A
-//
         %22%3CB%3E
@@ -739,34 +739,32 @@
 Method: %3C/B%3E%22 +%0A
-//
         req.getM
@@ -776,34 +776,32 @@
 () + %22%3CBR%3E%5Cn%22 +%0A
-//
         %22%3CB%3ERequ
@@ -809,34 +809,32 @@
 st URI: %3C/B%3E%22 +%0A
-//
         req.getR
@@ -854,26 +854,24 @@
  %22%3CBR%3E%5Cn%22 +%0A
-//
         %22%3CB%3E
@@ -896,18 +896,16 @@
 %3C/B%3E%22 +%0A
-//
         

Add features to TraceWebAgent.