You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Hance, Greg (ELS)" <G....@Elsevier.com> on 2005/06/06 17:24:13 UTC

How to add metadata to a binary response?

Hello,

We have an interesting problem that I'm somewhat at a loss as to how to
implement so I'm turning to my fellow Cocoon cronies for some ideas.

Basically, I'm looking for a way to add metadata to an arbitrary binary
response and I'd also like to do this in a way that is cacheable through
Cocoon. Most of our output from Cocoon (pipelines) return XHTML so we just
use HTML meta tags to return additional metadata w/ these requests - which
works nicely in that it gets serialized and cached as well.

We have a few pipelines that use custom Cocoon readers that we also need to
return metadata with - the output of these pipelines are binary and return
various image formats (JPEG, GIF) and also some PDFs. The problem is that we
also need to return some metadata along w/ these requests.

Has anyone ever done something like this or have any ideas? The only idea I
can think of would be to actually convert the binary object into Base64 or
something and serialize it as XML along w/ some metadata also in XML. These
seems a little roundabout though.

Another idea I had was to maybe HTTP response metadata / directives but the
only problem w/ that is that I wouldn't know how to handle setting something
in the response (or might not have an opportunity) if the request was
cached.

Any help is appreciated!

TIA, Greg  



_______________________
Greg Hance, Tech-Partners

Elsevier, eDevelopment
11830 Westline Industrial Dr. 
St. Louis, MO 63146

Phone: 314.995.3258


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: How to add metadata to a binary response?

Posted by Geert Josten <Ge...@daidalos.nl>.
> Has anyone ever done something like this or have any ideas? The only idea I
> can think of would be to actually convert the binary object into Base64 or
> something and serialize it as XML along w/ some metadata also in XML. These
> seems a little roundabout though.
> 
> Another idea I had was to maybe HTTP response metadata / directives but the
> only problem w/ that is that I wouldn't know how to handle setting something
> in the response (or might not have an opportunity) if the request was
> cached.

How about response headers?

In flowscript you can do cocoon.response.setHeader('name', 'value') in front of a cocoon.sendPage 
that provides the actual binary data or you can use the <map:act type="set-header"> with 
<map:parameter>'s to add headers.

When using flowscript, the binary data has to be provided with a separate pipe, so I expect that 
that pipe is cached as usual, while the flowscript function that adds the headers and redirect the 
data has to be called each time again.

If response headers are a solution, than give it a try. You might even consider using request 
headers for HTML responses as well...

Cheers,
Geert

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org