Grzegorz Kossakowski skrev:
Daniel Fagerstrom pisze:
Grzegorz Kossakowski skrev:
The current architecture is based on the assumption that the creation
of the response header must be completely finished before the creation
of the response body starts. I.e. that response header creation must
be done in the setup rather than in the pipeline execution. I think
(but haven't checked all possible consequences) that this is an
unnecessarily restrictive assumption. AFAICS it would be enough to
require that the creation (and output) of the response header is
finished before the response body starts to be emitted.
With such a less restrictive assumption, it would be OK to set
response headers as I suggested above.
I wonder how to achieve this less restrictive assumption. In
AbstractProcessingPipeline#setMimeTypeForSerializer() there is:
if (mimeType != null) {
environment.setContentType (mimeType);
} else {
// No mimeType available
String message = "Unable to determine MIME type for " +
environment.getURIPrefix() + "/" + environment.getURI();
throw new ProcessingException(message);
}
We have to move this checking somewhere further in the processing but I
have no good idea where exactly. Ideas?
I don't see any possibility to do this in the pipeline. My idea was to
do the mime type setting (on the http response object) in the
endDocument method of the ServletServiceSerializer. It could be done
after the:
IOUtils.copy(new StringReader(serializedXML),
servletSource.getOutputStream());
but before:
IOUtils.copy(servletSource.getInputStream(), super.output);
The http response object is available from the object model.
/Daniel