[mapserver-users] wfs post and mapscript
Andy Colson
andy at squeakycode.net
Sat Oct 17 08:44:57 PDT 2009
Holger Porath wrote:
> Hi all,
>
> I am trying to use perl mapscript for a WFS and it works for get
> requests. For post requests I get the following error message:
> POST body is short
>
> I am setting the parameters by calling the method loadParams(). Do I
> have to use msIO_installStdinFromBuffer(). And if so, how do I send the
> parameters to the buffer?
>
> Thanks in advance.
>
> Cheers
> Holger Porath
>
> Sorry for posting this twice, the prvious post was on the wrong mailing
> list.
>
> -------------------------------------------
> Dipl. Wirt. Inform. Holger Porath
> Wangeroogestraße 63
> 45665 Recklinghausen
Are you using cgi or fastcgi or mod_perl?
what version of mapserver (cuz < 5.6 needs patches)
I have mod_perl code, doing wms, with mapserver 5.6beta3. Here is some of my code:
With taint mode enabled, you need to untaint before calling setParameter:
$owreq = new mapscript::OWSRequest();
my @par = $web->paramNames();
for my $x (@par)
{
# taint mode is fickle...
my $xx = undef;
my $vv = undef;
if ($x =~ /([\w_]+)/)
{
$xx = $1;
} else {
next;
}
my $v = $web->param($x);
if ($v =~ /([\w,.:\/]+)/)
{
$vv = $1;
} else {
$vv = '';
}
$owreq->setParameter($xx, $vv);
}
then later on, to process the request, I do:
mapscript::msIO_installStdoutToBuffer();
$x = $map->OWSDispatch( $owreq );
if ($x)
{
my $errObj = new mapscript::errorObj();
while ($errObj) {
print STDERR "ERROR: $errObj->{code}:$errObj->{message}:$errObj->{routine}\n
";
$errObj = $errObj->next();
}
}
my $content_type = mapscript::msIO_stripStdoutBufferContentType();
$x = mapscript::msIO_getStdoutBufferBytes();
$web->content_type($content_type);
if (mapscript::msGetVersionInt() >= 50500)
{
print $$x;
} else {
print $x;
}
mapscript::msIO_resetHandlers();
With mapserver less than 5.6, you really need the patches for perl, otherwise this:
$x = mapscript::msIO_getStdoutBufferBytes();
returns unusable stuff.
-Andy
More information about the MapServer-users
mailing list