From 540362304c7af2c9e48f496aa6a153672481b7f3 Mon Sep 17 00:00:00 2001 From: randomdan Date: Tue, 8 Mar 2011 15:13:42 +0000 Subject: Don't shoehorn our HTTP response into a cgicc::status one, just implement ourself --- project2/cgi/cgiAppEngine.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/project2/cgi/cgiAppEngine.cpp b/project2/cgi/cgiAppEngine.cpp index e8c23e5..7df0279 100644 --- a/project2/cgi/cgiAppEngine.cpp +++ b/project2/cgi/cgiAppEngine.cpp @@ -1,6 +1,6 @@ #include "cgiAppEngine.h" #include -#include +#include #include "cgiEnvironment.h" #include "../xmlObjectLoader.h" #include "../iterate.h" @@ -20,12 +20,13 @@ SessionContainer * sessionsContainer = new SessionContainerXml(); SimpleMessageException(UnknownDomain); -class Project2HttpHeader : public cgicc::HTTPStatusHeader { +class Project2HttpHeader : public cgicc::HTTPHeader { public: typedef std::map Headers; - Project2HttpHeader(int c, const std::string & m, const std::string & t) : - cgicc::HTTPStatusHeader(c, m) + Project2HttpHeader(const std::string & s, const std::string & t) : + cgicc::HTTPHeader("") { + addHeader("Status", s); addHeader("Content-Type", t); } void addHeader(const std::string & name, const Glib::ustring & value) { @@ -36,7 +37,10 @@ class Project2HttpHeader : public cgicc::HTTPStatusHeader { BOOST_FOREACH(const Headers::value_type & h, headers) { out << h.first << ": " << h.second << std::endl; } - cgicc::HTTPStatusHeader::render(out); + BOOST_FOREACH(const cgicc::HTTPCookie & cookie, getCookies()) { + out << cookie << std::endl; + } + out << std::endl; } private: Headers headers; @@ -160,7 +164,7 @@ CgiApplicationEngine::PresentStage::run() CgiApplicationEngine::HttpHeaderPtr CgiApplicationEngine::PresentStage::getHeader() const { - Project2HttpHeader * header = new Project2HttpHeader(200, "OK", contentType); + Project2HttpHeader * header = new Project2HttpHeader("200 OK", contentType); header->addHeader("Cache-control", "no-cache"); return HttpHeaderPtr(header); } @@ -255,7 +259,7 @@ CgiApplicationEngine::RequestStage::run() CgiApplicationEngine::HttpHeaderPtr CgiApplicationEngine::RequestStage::getHeader() const { - return HttpHeaderPtr(new Project2HttpHeader(200, "OK", "text/xml")); + return HttpHeaderPtr(new Project2HttpHeader("200 OK", "text/xml")); } CgiApplicationEngine::XmlDocPtr @@ -341,7 +345,7 @@ CgiApplicationEngine::NotFoundStage::~NotFoundStage() CgiApplicationEngine::HttpHeaderPtr CgiApplicationEngine::NotFoundStage::getHeader() const { - return HttpHeaderPtr(new Project2HttpHeader(404, "Not found", env->errorContentType)); + return HttpHeaderPtr(new Project2HttpHeader("404 Not found", env->errorContentType)); } const Glib::ustring CgiApplicationEngine::NotFoundStage::resp("notfound"); @@ -375,7 +379,7 @@ CgiApplicationEngine::ErrorStage::~ErrorStage() CgiApplicationEngine::HttpHeaderPtr CgiApplicationEngine::ErrorStage::getHeader() const { - return HttpHeaderPtr(new Project2HttpHeader(500, "Internal Server Error", env->errorContentType)); + return HttpHeaderPtr(new Project2HttpHeader("500 Internal Server Error", env->errorContentType)); } const Glib::ustring CgiApplicationEngine::ErrorStage::resp("error"); -- cgit v1.2.3