Hi Mike,
> I think there's a bug in javax.servlet.http.HttpServlet, but I'm not
sure where to report it.
> I'm posting this here for the time being (and possibly on the
Glassfish "issue tracker" if and
> when I can jump through the hoops required to do so), but please let
me know if it ought to be
> reported some other way: and apologies if this doesn't belong here!
I found another problem with HttpServlet's NoBodyOutputStream: If you use
getWriter(), the returned writer is constructed as follows:
OutputStreamWriter w = new OutputStreamWriter(
noBody, getCharacterEncoding());
writer = new PrintWriter(w);
Notice that when you wrap an OutputStreamWriter around noBody, the
output will be buffered by the OutputStreamWriter before it is written
to "noBody", meaning that when NoBodyOutputStream.setContentLength()
is called, noBody.getContentLength() will return 0 if the output is still
buffered. Therefore, NoBodyOutputStream.setContentLength() needs to
flush the writer (if one is being used) before calling
noBody.getContentLength(),
as follows:
void setContentLength() {
if (!didSetContentLength) {
// BEGIN PATCH
if (writer != null) {
writer.flush();
}
// END PATCH
setContentLength(noBody.getContentLength());
}
}
Let me know what you think.
Thanks,
Jan
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]