Hi Tommi
You were correct, there were extra lines between the ecpp tags however I
would like to understand why these are only sent when I add the
reply.setContentType line:
<%pre>
#include <fstream>
#include <tnt/mimedb.h>
#include "jsoncpp/json/json.h"
using namespace std;
</%pre>
<%args>
r = ""; // Random number.
t = ""; // Users primary group (user type).
</%args>
<%cpp>
std::string vtxFile = request.getPathInfo();
std::string vtxBody = request.getBody();
log_info("Requested body: " + vtxBody);
Json::Value root;
Json::Reader reader;
bool parsedSuccess = reader.parse(vtxBody,root, false);
if ( !parsedSuccess ) {
reply.out( ) << "{\"success\": false, \"reason\": \"Failed to
parse incoming json\"}";
}
std::cout << root;
log_info("Returning: " + vtxFile + " from webio...");
std::ifstream in(vtxFile.c_str());
if (!in) {
log_info("Could not find: " + vtxFile);
return DECLINED;
}
tnt::MimeDb mimeDb("/etc/mime.types");
// Adding next line includes line breaks if any exist in this file
reply.setContentType(mimeDb.getMimetype(vtxFile));
reply.out() << in.rdbuf();
</%cpp>
------------------------------------------------------------------------------
How fast is your code?
3 out of 4 devs don\\\'t know how their code performs in production.
Find out how slow your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219672;13503038;z?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general