cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luigi Bai <lpb+coc...@focalpoint.com>
Subject Re: When to set mime-type
Date Wed, 27 Oct 2004 17:12:33 GMT


On Wed, 27 Oct 2004, Unico Hommes wrote:

> Luigi Bai wrote:
>
>> 
>> 
>>>> And Cocoon already has shouldSetContentLength(), which tells the pipeline

>>>> that at least ContentLength happens later in the processing (and of 
>>>> course the output has to be buffered). If that is not set, the general 
>>>> case is to stream without contentLength.
>>> 
>>> 
>>> 
>>> shouldSetContentLength doesn't tell the pipeline that content length 
>>> happens later in the pipeline, it tells the pipeline it ought to do 
>>> whatever it can to determine the content length. It happens to do that by 
>>> buffering the output.
>>> 
>>> Anyway, I think content length is a special case since there is no general 
>>> mechanism - like there is with mime-type - to determine it in advance.
>>> 
>> 
>> Well, there's only a "general mechanism" to determine mime-type in advance 
>> if you require it to be set in advance. That's a circular argument! :-) 
>
>
> That's not what the argument was about though. The point is that there is no 
> way to determine the content-length berforehand. In this way content lenght 
> is different from mime-type.
>

Not really different; a call to fstat() (File.length()?) can determine the 
size of a file before it's streamed. I think the point is that sometimes 
it's possible to know these things ahead of time and sometimes not. Right 
now, it's not possible in Cocoon AFAIK to deal with the case when you 
can't know this information up front.

And I'm not saying this would be something easy to change in Cocoon. From 
just my cursory glance at the code (and I'm a newbie), it looks like many 
places in the Pipeline Processing assume this information is available 
after setup(). It would require more changes to be able to handle the 
Pipeline being able to set information.

>> My point is that in a data-driven model, the pipeline may not know until 
>> the Serializer has started processing the stream (and not just at setup() 
>> but after startDocument()) what the characteristics of the data are. Since 
>> the Response headers are supposed to reflect what the data is, shouldn't it 
>> be possible for the data to influence what headers are sent to represent 
>> it? 
>
>
> OK. In some special cases, the data that flows through the pipeline 
> determines the characteristics of the outputted data, ie. it is only 
> available by actually processing the pipeline, and it cannot be determined 
> beforehand. In this case you want a mechanism to set the mime-type during 
> that processing stage. But such a mechanism exists in Cocoon, just not by 
> interfacing with the ProcessingPipeline but by using the  Response object in 
> the Serializer directly. I think the best way to solve this is using that.
>

I will try that approach sometime soon. Unfortunately I am currently being 
consumed by another part of my project!

Thanks;
Luigi

>
> --
> Unico
>

Mime
View raw message