#include "IMFResponse.h"
#include "Log.h"

namespace coreutils {

   IMFResponse::IMFResponse() {}
   IMFResponse::~IMFResponse() {}

   std::stringstream IMFResponse::getResponse(Mode mode) {
      std::stringstream stream("");
      return getResponse(stream, mode);
   }

   std::stringstream IMFResponse::getResponse(std::stringstream &content, Mode mode) {
      std::stringstream response;
      response << protocol << " " << code << " " << text << CRLF;

      if(mode == LENGTH) {
         sprintf(contentLength, "%li", content.str().length());
         ZString conlen(contentLength);
//         addHeader(IMFHeader("Content-Length", conlen));
      }
      else
//        addHeader(IMFHeader("Transfer-Encoding", "chunked"));

//      addHeader(IMFHeader("Server", "JETServer v0.0.1"));

//      output(response);
      response << content.str();
      return response;
   }

   void IMFResponse::setProtocol(ZString protocol) {
      this->protocol = protocol;
   }

   void IMFResponse::setCode(ZString code) {
      this->code = code;
   }

   void IMFResponse::setText(ZString text) {
      this->text = text;
   }

}
