Am 27.09.2012 22:26, schrieb Paul:
> If I use reply.setContentType("application/json") to return a json file
> tntnet adds unwanted spaces or line returns to the front of the reply
> sent to the browser. If this reply is json, then jquery fails to parse
> on Android devices (two that I tested) with SyntaxError: Unexpected
> token ILLEGAL. Does not fail on FF or IE.
>
> std::ifstream in(vtxJsonFile.c_str());
> if (!in) {
> return DECLINED;
> }
>
> tnt::MimeDb mimeDb("/etc/mime.types");
> reply.setContentType(mimeDb.getMimetype(vtxJsonFile)); //This
> appears to add spaces to the front which borks android.
> // so does reply.setContentType("application/json")
>
> reply.out() << in.rdbuf();
>
> static@tntnet works fine.
I can't believe it. reply.setContentType does nothing with the reply
body. Are you sure this line is responsible for that? It is so easy to
add empty lines in ecpp. A common problem is to add empty lines between
ecpp tags. Like that:
<%args>
...
</%args>
<%cpp>
...
</%cpp>
Not that line feeds after the closing ecpp tags are ignored but if the
file has dos line endings there is a cr before the lf and then the line
feed is not ignored.
Do you have a full example, I can try to reproduce your problem?
Tommi
------------------------------------------------------------------------------
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