forwarded message:

Subject: Re: no way to get content-type?
Date: Mon, 13 May 2002 19:20:18 +0200
From: "Jens Lorenz" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>

----- Original Message -----
From: "Andreas Vallen" <[EMAIL PROTECTED]>
To: "Jens Lorenz" <[EMAIL PROTECTED]>
Sent: Monday, May 13, 2002 6:59 PM
Subject: Re: no way to get content-type?

> Hello Jens,
>
> Thanks for your suggestions.
>
> > map:generate creates a stream of sax events. No MIME content type can
> > be applied to this. The content type of the URLSource is actually
> > determined by the Web-Server according to the extension of the file
> > it sends.
>
> Actually URLSource looks up the HTTP-Header for the content-type
> (method: connection.getContentType). But it does so only to distinguish 
> between HTML and XML Sources.

Yes. And this Header gets set by the HTTP server ...

> > Looking at your sitemap example, might it be the case that you don't
> > want to determine the contenttype but the (XML) doctype of the
> > SAX stream ?
>
> No, it's really the contenttype (Mimetype) of the HTTP-Response I'm
> interested in.
>
> You suggest another way to achieve my goal. Unfortunately
> this solution doesn't account for resources without descriptive
> file-extensions.
> If I wanted to transform the document "wap.yahoo.de" it wouldn't work.
>
> slightly changed to express what I think you meant ;-) :
>
> <map:match pattern="**.wml"/>
>  <map:generate src="{1}.wml" type="file" />
>    <map:transform src="wml2xhtml.xsl"/>
>    <map:serialize type="xhtml" />
>  </map:generate>
> </map:match>
>
> <map:match pattern="**.chtml"/>
> <map:generate src="{1}.chtml" type="file" />
>    <map:transform src="chtml2xhtml.xsl"/>
>    <map:serialize type="xhtml" />
>  </map:generate>
> </map:match>

Now I got your point ... Of course this doesn't work for dynamic
web pages without extensions.

This way it gets a bit more complicated ... You need to get the
ContentType header and feed it somehow into the pipeline.

Well, it's not the best way, but a possible one:

Write an Action which uses the URL to send a HEAD-Request to the
HTTP-Server, get the Content-Type header and put it into the
(Cocoon) Request. Then use a RequestMatcher.

Or return the value within a HashMap from the Action and use
substitution with {}.

I think modifying URLSource to store the content-type somewhere
will only lead into lots of trouble (not having the objectModel,
threading issues, etc.)

The first way of course will send two Requests (one GET, one HEAD)
two the WebServer of the source, which is not desirable as well.


Looking at the source code of Source and AbstractStreamSource I can
also think of no other way of achieving this without breaking
design patterns of Cocoon. Maybe Vadim got a better idea ?

> Greetings,
> Andreas

Regards,


Jens

--

jens.lorenz at interface-projects dot de

interface:projects GmbH                             \\|//
Tolkewitzer Strasse 49                              (o o)
01277 Dresden                               ~~~~oOOo~(_)~oOOo~~~~
Germany

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

Reply via email to