[Mapserver-dev] additional parameters for WMS  layer

Mike V. Andreev andreev at d902.iki.rssi.ru
Fri May 16 13:34:57 EDT 2003


I have mapserever compiled with WMS client support and I use map file
with defined WMS layer. This layer is a http reference to my perl script
on the same http server. This script understand OGC WMS parameters in
query string and can create maps whith information from some database.
But to  create sensible map this script need additional information in
request. I wanted to use http cookies to store that parameters. But I
have a problem here. Then my client send request to http server with
mapserver URI request contain proper cookies but after that mapserver
need to make http request to perl script URI and of couse this request
contains no cookies.

So I want to ask two question here:

1) Can somebody give me any hits to solve my problem with existing soft?

2) I have an idea how to extend mapserver functionality so it be able to
solve my problem. So I want to ask what do you people think about it.

There is my proposal: each layer object could contain boolean parameter
http_cookies_forwad (disabled by default). So if this featcher enabled
in layer with connectiontype equal to 'WMS' (and may be 'WFS') than when
mapserver make http request to proper URL it sends additional http
headers: 1) Cookie - header with cookies client send to mapserver and 2)
X-Forwarder-For - header with original client ip (as far as mapserver
can determine it).

Just to illustrate my idea I've made simple patch to maphttp.c. I used
today's (2003-05-16) nightly build. This patch contains only
functionality for sending proper http request. There is no any stuff to
support new feature in layreObj but I think whole idea is clear.

>     char     *tmp_env_read, *strBuf = NULL;
>     struct curl_slist *slist=NULL;
>         /* If we need to forward http cookies to server  */
>         if( HTTP_COOKIES_FORWARDING && (tmp_env_read = curl_getenv( "HTTP_COOKIE" ) ) != NULL ){
>            /*add cookies to http_handle*/
>            curl_easy_setopt(http_handle, CURLOPT_COOKIE, tmp_env_read);
>           /*add X-Forwarded-For header with original client ip */
>            if( (tmp_env_read = curl_getenv( "HTTP_X_FORWARDED_FOR" ))  == NULL )
>               if( (tmp_env_read = curl_getenv( "HTTP_FORWARDED" ) ) == NULL )
>                  if( (tmp_env_read = curl_getenv( "HTTP_CLIENT_IP" ) ) == NULL )
>                     tmp_env_read = curl_getenv( "REMOTE_ADDR" );
>            if( tmp_env_read != NULL ){
>               strBuf = (char*)malloc( HTTP_HEADER_BUF_LENGTH );
>               snprintf( strBuf, HTTP_HEADER_BUF_LENGTH, "X-Forwarded-For: %s", tmp_env_read);
>               slist = curl_slist_append( slist, strBuf);
>               curl_easy_setopt(http_handle, CURLOPT_HTTPHEADER, slist);
>            }
>        }
>     if( slist != NULL ){ curl_slist_free_all(slist); }
>     if( strBuf != NULL ){ free( strBuf ); }

| Mike Andreev, software engineer andreev at d902.iki.rssi.ru   |
| SMIS Lab, Space Research Institute http://smis.iki.rssi.ru |

More information about the mapserver-dev mailing list