[mapserver-dev] Can msIO_stripStdoutBufferContentHeaders() return
headers and be available through MapScript?
Daniel Morissette
dmorissette at mapgears.com
Mon Jun 13 12:08:15 EDT 2011
Maybe we couold add a new ms_ioExtractStdoutBufferHeaders() that would
extract and return all headers in an array?
On 11-06-13 11:59 AM, Stephan Meißl wrote:
> Jean-François,
>
> in 6.0 the exact function you propose was added (see [1]). It doesn't
> return the headers though. I haven't tested the function in PHP
> MapScript but it works with Python.
>
> cu
> Stephan
>
> [1] http://mapserver.org/mapscript/mapscript.html#mapscript-functions
>
>
> On Mon, 2011-06-13 at 15:27 +0200, Jean-François Gigand wrote:
>> Hi,
>>
>> I use PHP MapScript and handle WxS requests through the "MapScript
>> Wrappers for WxS Services", which work fine.
>>
>> Since 6.0 I also use OGR output (ZIP of CSV/Shapefiles), which also
>> works fine (much thanks, 6.0 kicks ass!).
>>
>> Through {,Fast}Cgi, everything is fine.
>> But, through (PHP) MapScript, when the WxS request outputs a
>> "Content-Disposition" header, the ms_ioStripStdoutBufferContentType()
>> function is of no use, as the Content-Type header is not the first
>> one, and no MapScript method would extract the "Content-Disposition"
>> header anyway.
>>
>> To my guess, the perfect solution would be a
>> msIO_stripStdoutBufferContentHeaders() function which:
>> - would return the headers, not just strip them off, for example
>> returning a<char **>
>> - would be available through MapScript
>>
>> If you confirm the need for this solution, I can develop it and send you a patch
>> (just advise me about the function name and prototype (<char***> param
>> or<char**> return?).
>>
>> So far, I have done this through PHP, see the function below:
>>
>> /**
>> * Strip off Content-* headers from buffer and set them on response object
>> *
>> * @param $buffer string Ref to buffer string, which may
>> include Content-* headers
>> * @param $reponse Response Framework-dependant response object to
>> add the headers to
>> */
>> function extractContentHeaders(&$buffer, Response $response)
>> {
>> $length = -1;
>> $regex = "/^(Content-[a-zA-Z-]+): ([a-zA-Z0-9.\/=?!_; -]+)\n/";
>> while (strlen($buffer) != $length) {
>> $length = strlen($buffer);
>> $cb = function($m) use ($response) {
>> $response->headers->set($m[1], $m[2]);
>> return '';
>> };
>> $buffer = preg_replace_callback($regex,$cb, $buffer);
>> }
>> }
>>
>>
>> Best regards,
>>
>> JF Gigand
>> _______________________________________________
>> mapserver-dev mailing list
>> mapserver-dev at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/mapserver-dev
>
>
> _______________________________________________
> mapserver-dev mailing list
> mapserver-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-dev
--
Daniel Morissette
http://www.mapgears.com/
Provider of Professional MapServer Support since 2000
More information about the mapserver-dev
mailing list