[mapserver-dev] Can msIO_stripStdoutBufferContentHeaders() return
 headers and be available through MapScript?
    Jean-François Gigand 
    jean-francois at gigand.fr
       
    Mon Jun 13 09:27:03 EDT 2011
    
    
  
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
    
    
More information about the mapserver-dev
mailing list