[Mapserver-users] Sending image to stdout under Apache

Jason Thaxter thaxter at gomoos.org
Thu Mar 6 13:52:38 PST 2003


I'll try to re-sum this up...

The problem is that mod_perl ties stdin and stdout to sockets that aren't
"real" stdin and stdout.  This is so you can just "print" in an
Apache::Registry script and have it go to the browser.

But perl libraries that write to stdout in C, as the mapserver module does,
end up sending their data to Apache's stdout, which is usually outer space.
You can confirm that it goes to Apache's stdout by running your apache in
foreground mode by doing "httpd -X" and seeing the PNG data fly across the
terminal window when you call $img->saveImage(undef,etc);

Here is an example of someone else with the same problem using a totally
different perl module:
	http://www.ee.ethz.ch/~slist/rrd-users/msg01503.html
Frankly this could be regarded as a mis-design of mod_perl; on the other hand,
it's a Good Thing to be able to get data out of the mapserver objects via
filenames AND filehandles AND references to pure image data...

The solution is to write a variant of the saveImage function where instead of
passing a filename, you pass a PERL filehandle, e.g.:
	$img->saveImage(*STDOUT,etc)

This is easy; in fact I've already done it in the C code and gotten it into
the perl module, but it doesn't quite work for reasons that have to do with
SWIG stuff: I'm looking for help in SWIG land at the moment, but if any
mapserver developers have insight, I'd be happy to take this to private
discussion or the developer's list.

As soon as they actually work, I'll make my patches available for use,
discussion, improvement, and hopefully, inclusion in mapserver.

Jason

On Thu, Mar 06, 2003 at 09:42:05AM -0800, Dana Quinn wrote:
> 
> So this is mainly a problem because it's difficult
> to output directly to the browser when using mod_perl?
> (difficult to make sure your content header goes to the
> browser first, and then the actual image?)
> 
> it's hard to believe there isn't a straightforward way
> to make this happen in mod_perl.
> 
> dana
> 

-- 
----------------------------------------------
Jason Thaxter
GoMOOS, P.O. Box 4919, Portland, ME 04112-4919
Office Location: 1 Canal Plaza, 7th Floor
Office: 207.773.0423
Fax:    207.773.8672
Email:  thaxter at gomoos.org
------------www.gomoos.org--------------------



More information about the MapServer-users mailing list