Return-Path: Delivered-To: apmail-cocoon-dev-archive@www.apache.org Received: (qmail 57831 invoked from network); 27 Oct 2004 16:06:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 27 Oct 2004 16:06:47 -0000 Received: (qmail 88610 invoked by uid 500); 27 Oct 2004 16:06:44 -0000 Delivered-To: apmail-cocoon-dev-archive@cocoon.apache.org Received: (qmail 88350 invoked by uid 500); 27 Oct 2004 16:06:43 -0000 Mailing-List: contact dev-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: dev@cocoon.apache.org Delivered-To: mailing list dev@cocoon.apache.org Received: (qmail 88337 invoked by uid 99); 27 Oct 2004 16:06:42 -0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of lpb+cocoon@focalpoint.com designates 66.237.148.186 as permitted sender) Received: from [66.237.148.186] (HELO mailhost.focalpoint.com) (66.237.148.186) by apache.org (qpsmtpd/0.28) with ESMTP; Wed, 27 Oct 2004 09:06:41 -0700 Received: from nexxus.focalpoint.com (nexxus.focalpoint.com [199.245.124.34]) by mailhost.focalpoint.com (Postfix) with ESMTP id B75D7706A8 for ; Wed, 27 Oct 2004 11:04:23 -0500 (CDT) Date: Wed, 27 Oct 2004 11:04:23 -0500 (CDT) From: Luigi Bai To: dev@cocoon.apache.org Subject: Re: When to set mime-type In-Reply-To: <417FC2B3.6050403@hippo.nl> Message-ID: References: <20041026170705.84208.qmail@minotaur.apache.org> <417E8954.70600@hippo.nl> <417E90F2.605@reverycodes.com> <417F8BA3.9090805@hippo.nl> <417FB3B6.80709@hippo.nl> <417FC2B3.6050403@hippo.nl> X-Habeas-SWE-1: winter into spring X-Habeas-SWE-2: brightly anticipated X-Habeas-SWE-3: like Habeas SWE (tm) X-Habeas-SWE-4: Copyright 2002 Habeas (tm) X-Habeas-SWE-5: Sender Warranted Email (SWE) (tm). The sender of this X-Habeas-SWE-6: email in exchange for a license for this Habeas X-Habeas-SWE-7: warrant mark warrants that this is a Habeas Compliant X-Habeas-SWE-8: Message (HCM) and not spam. Please report use of this X-Habeas-SWE-9: mark in spam to http://www.habeas.com/report/. MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Focal-Point-Software-Inc-MailScanner-Information: Please contact the ISP for more information X-Focal-Point-Software-Inc-MailScanner: Found to be clean X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N On Wed, 27 Oct 2004, Unico Hommes wrote: > Luigi Bai wrote: > >> >> >>> Exactly. This is the problem with delaying the setting of the mime type. >>> For the general case we'd always have to buffer the whole response which >>> isn't practical. >>> >> >> Well, according to the Servlet spec, you really should set ContentType >> before beginning the output stream, especially if you're using a Writer and >> not an OutputStream (for charset to be handled correctly). So it seems >> orthogonal to buffering. >> > > Huh? Probably we mean the same thing. In an http response, header come before > body, otherwise its not a valid http response. With "buffering" I mean the > process of stalling the streaming of the response body for a specified amount > of bytes in order to allow modification of the response headers. Be that by > physically setting an output buffer size in the Servlet API or brewing up > something external to it. So one has a lot to do with the other. > Yes, we mean the same thing. I was just pointing out that in a pipeline, it's not always the case that _anything_ has streamed out (needs to be buffered) by the time the headers are all ready - even if the headers are set in the Serializer. So, it's an observation about the Cocoon workflow, not headers and buffering in general. >> 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! :-) 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? The Servlet spec, with all its redirects and includes, makes it possible, although with many cautions about flushing etc. >> >> I'd propose a shouldSetContentType(), which would be a special case (not >> the general case); it would tell the pipeline to wait to send output until >> the contentType is set. This may or may not cause buffering; indeed, in the >> use-case I described, nothing is sent to the output stream by the time the >> image content-type is known. >> >>> What you could do instead is to manually set the response header in the >>> serializer and make sure the pipeline that processes the response has a >>> large enough buffer. You can set the outputBufferSize parameter either >>> during the pipe's configuration or using a sitemap parameter. >>> >> >> Is it true that setting response headers in the Serializer will be >> respected? It's not clear that's true in all cases - various Wrapped >> Responses throw that away. I think it should be more explicitly part of the >> workflow. >> > > A Serializer will never deal with WrappedEnvironments AFAICS. Internal xml > pipeline processing is pipeline minus Serializer. > I didn't know that. However: if the content is being "streamed" to the client, at what point are the headers sent? Can it be said for certain that a Serializer can set headers after startDocument(), and these headers are sent to the client? I have to admit I have not tried that; the description of the workflow, and my admittedly cursory review of the code, discouraged me from that experiment. Thanks; Luigi > -- > Unico > >