summaryrefslogtreecommitdiffabout
path: root/lib/sitecing_interface_cgi.cc
blob: 5c3d2951912b304770ff749d85c3073860b3889b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <cassert>
#include "sitecing/sitecing_interface_cgi.h"

namespace sitecing {

    sitecing_interface_cgi::sitecing_interface_cgi(sitespace *s)
	: sitecing_interface(&prebuffer), ss(s), cgigw(NULL) {
	}

    void sitecing_interface_cgi::prepare(kingate::cgi_gateway *cg) {
	cgigw = cg;
	headers.clear();
	headers["Content-Type"] = "text/html";
	prebuffer.str("");
    }

    void sitecing_interface_cgi::flush() {
	assert(cgigw);
	for(headers_t::const_iterator i=headers.begin();i!=headers.end();i++)
	    cgigw->out() << i->first << ": " << i->second << "\n";
	(cgigw->out() << "\n").write(prebuffer.str().c_str(),prebuffer.tellp());
	cgigw->out().flush();
    }

}