[Simpleweb-Support] outputstream flush in BasicResource
Brought to you by:
niallg
|
From: Christophe R. <cr...@ac...> - 2005-05-18 15:10:24
|
Hi,
I a using simpleweb to do some remote invocation with the Spring framework.
Works like a charm, I just have a little problem on error processing:
I have a class that extends ProtocolHandler, it just checks if the request
is zipped and does the appropriate treatment if needed (wrapped the stream
in a gzip stream). I then have a class that extends BasicService that simply
do the method invocation.
The only problem I have is with a corrupted zip request. An Exception is
raised and processed by BasicResource:
public void process(Request req, Response resp, Report report) throws
Exception{
Format format = context.getFormat();
byte[] page = format.getMessage(
context, req.getURI(), report);
resp.setCode(report.getCode());
resp.setText(report.getText());
resp.setDate("Date", System.currentTimeMillis());
resp.setContentLength(page.length);
resp.set("Content-Type", format.getMimeType());
resp.getOutputStream().write(page);
// --
resp.getOutputStream().flush(); // flush added
resp.getOutputStream().close();
}
I have added a flush on the stream otherwise the response is not received by
the client.
I don't know if it is a bug but it fixed my little problem.
Christophe
|