Hi,

I think I've found a bug in the static component.

Suppose we have the following tntnet.xml:

------------------------------------------------
<mapurl>
  <url>^/$</url>
  <target>check_if_authorized@my_fancy_library</target>
</mapurl>
<mapurl>
  <url>^/$</url>
  <target>static@tntnet</target>
  <pathinfo>index.html</pathinfo>
</mapurl>
------------------------------------------------

And we have check_if_authorized.ecpp:

------------------------------------------------
<%pre>
#include <...>
...
</%pre>


<%cpp>
...
if (authorized)
  return DECLINED;
else
  throw tnt::HttpError(403);
</%cpp>
------------------------------------------------
(note the 2 newlines between </%pre> and <%cpp>

Now, if we visit the path '/' on the server, this causes the code in
check_if_authorized@my_fancy_library to be executed first, inserting 2
newlines in the response. Because 'check_if_authorized' returns
DECLINED, static@tntnet takes over and appends 'index.html' to the
response. The response now contains 2 newlines followed by the contents
of 'index.html'. However, in the response, the last 2 characters of
'index.html' are missing.

This probably has to do with line 373 of
/tntnet-2.2.1/framework/defcomp/static.cpp

reply.setContentLengthHeader(count);

This has to be replaced by

reply.setContentLengthHeader(reply.getContentLengthHeader() + count);

Or maybe it's even better if responses from the static component "clear"
all stuff that was previously written to reply.out() by other components.

In my case, this 'bug' was easily worked around by not letting
check_if_authorized insert newlines in the response. But still, I had a
lot of trouble finding out the cause of these 'missing characters' at
the end of responses. Could maybe cause trouble for other people as well...

Have a nice day,
Joeri

------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general

Reply via email to