/*
 * Copyright 2010 MQWeb - Franky Braem
 *
 * Licensed under the EUPL, Version 1.1 or  as soon they
 * will be approved by the European Commission - subsequent
 * versions of the EUPL (the "Licence");
 * You may not use this work except in compliance with the
 * Licence.
 * You may obtain a copy of the Licence at:
 *
 * http://joinup.ec.europa.eu/software/page/eupl
 *
 * Unless required by applicable law or agreed to in
 * writing, software distributed under the Licence is
 * distributed on an "AS IS" basis,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied.
 * See the Licence for the specific language governing
 * permissions and limitations under the Licence.
 */
#include "MQ/Web/JSONView.h"

namespace MQ {
namespace Web {

JSONView::JSONView() : 
	View()
{
}


JSONView::~JSONView()
{
}

void JSONView::initializeResponse(Poco::Net::HTTPServerResponse& response)
{
	response.setChunkedTransferEncoding(true);
	response.setContentType("application/json");
}

bool JSONView::render(Poco::JSON::Object::Ptr data, std::ostream& os)
{
	data->stringify(os);
	os.flush();
	return true;
}


}} // Namespace MQ::Web

/*
 * Copyright 2010 MQWeb - Franky Braem
 *
 * Licensed under the EUPL, Version 1.1 or  as soon they
 * will be approved by the European Commission - subsequent
 * versions of the EUPL (the "Licence");
 * You may not use this work except in compliance with the
 * Licence.
 * You may obtain a copy of the Licence at:
 *
 * http://joinup.ec.europa.eu/software/page/eupl
 *
 * Unless required by applicable law or agreed to in
 * writing, software distributed under the Licence is
 * distributed on an "AS IS" basis,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied.
 * See the Licence for the specific language governing
 * permissions and limitations under the Licence.
 */
#include "MQ/Web/JSONView.h"

namespace MQ {
namespace Web {

JSONView::JSONView() : 
	View()
{
}


JSONView::~JSONView()
{
}

void JSONView::initializeResponse(Poco::Net::HTTPServerResponse& response)
{
	response.setChunkedTransferEncoding(true);
	response.setContentType("application/json");
	response.set("Cache-Controle", "no-cache,no-store,must-revalidate"); // HTTP 1.1
	response.set("Pragma", "no-cache"); // HTTP 1.0
	response.set("Expires", "0"); // Proxies
}

bool JSONView::render(Poco::JSON::Object::Ptr data, std::ostream& os)
{
	data->stringify(os);
	os.flush();
	return true;
}


}} // Namespace MQ::Web

Add headers for not caching JSON views on the client
Add headers for not caching JSON views on the client
