#include "__jet.h"
#include "Exception.h"
#include <iostream>

namespace jet {
   
   __jet::__jet(coreutils::ZString &in, coreutils::MString &parent, Global &global) : Tag(in, parent, global) {
      if(variables["cgi"] == "true") {
	 coreutils::ZString requestMethod(getenv("REQUEST_METHOD"));
	 if(requestMethod == "POST") {
	    coreutils::ZString contentLength(getenv("CONTENT_LENGTH"));
	    coreutils::ZString contentType(getenv("CONTENT_TYPE"));
	    if(contentType == "multipart/form-data") 
	      std::cout << "output multipart variables to global" << std::endl;
	    else if(contentType == "application/x-www-form-urlencoded") 
	      std::cout << "output urlencoded variables to global" << std::endl;
	 }	
      }
            
      try {	   
	 processContainer(container);
      }
      catch(coreutils::Exception e) {
	 std::cout << container.parsed() << std::endl;
	 std::cout << "***** " << e.text << std::endl; 
	 std::cout << container.unparsed() << std::endl;
	 throw e;
      }
      
   }
}

