tags:

views:

60

answers:

1

I am writing a CGI program (in C++) that will output the following data in its response:

  1. (inline) GIF image (i.e. octect stream)
  2. JSON
  3. Javascript
  4. XHTML

All the CGI examples I have seen are "trivial" and return only one data type. How can I return a response that contains all of the above ?

A: 

Well, I guess you can send a multipart response. If the client is a standard Web browser session, though, this will probably not go well. If you control the client's interpretation it may be what you want.

In some sense, you can send all four of the entities you're talking about by sending an XHTML document that contains the JSON and JavaScript data and an embedded image.

chaos
It's probably more usable to throw in some kind of "switch" that controls the output type. That way it can still be a single program but depending on its input it emits different things (though I question and doubt whether it's necessary to use a single program there as the responses are likely very different from each other).
Joey
It sounds like he wants to send them all at once, not alternately.
chaos
I agree, that's probably what s?he wants, but it may not necessarily be a good idea.
Joey
Strange thing to want, though, eh. What would a browser do with it?
bobince
Dunno. Maybe it's for Ajax interpretation, not browser session as such.
chaos
Hi chaos, you're right - its for AJAX. basically, I want to dump the response into an existing page (including the dynamically generated image). Basically, I want the response to behave like a "widget" if that makes sense. If there is a better way to "widgetify" my fastcgi app response, I would be glad to hear about it
scoobydoo