[Mapserver-dev] additional parameters for WMS layer

Mike V. Andreev andreev at d902.iki.rssi.ru
Fri May 16 12:59:52 EDT 2003


Hello

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 here two question:

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. I don't know 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.




81a82,83
> #define HTTP_COOKIES_FORWARDING 1
>
243a246,247
>     char     *tmp_env_read, *strBuf = NULL;
>     struct curl_slist *slist=NULL;
366a371,392
>         /* 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 ){
> #define HTTP_HEADER_BUF_LENGTH 100
>               strBuf = (char*)malloc( HTTP_HEADER_BUF_LENGTH );
>               snprintf( strBuf, HTTP_HEADER_BUF_LENGTH, "X-Forwarded-For: %s", tmp_env_read);
> #undef HTTP_HEADER_BUF_LENGTH
>               slist = curl_slist_append( slist, strBuf);
>               curl_easy_setopt(http_handle, CURLOPT_HTTPHEADER, slist);
>            }
>        }
>
>
554a581,583
>     if( slist != NULL ){ curl_slist_free_all(slist); }
>     if( strBuf != NULL ){ free( strBuf ); }
>
556a586,587
> #undef HTTP_COOKIES_FORWARDING
>

-- 
 ____________________________________________________________
| 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