[mapserver-commits] r7491 - in trunk/mapserver: . rfc
svn at osgeo.org
svn at osgeo.org
Tue Apr 1 17:34:40 EDT 2008
Author: jlacroix
Date: 2008-04-01 17:34:39 -0400 (Tue, 01 Apr 2008)
New Revision: 7491
Modified:
trunk/mapserver/HISTORY.TXT
trunk/mapserver/cgiutil.c
trunk/mapserver/cgiutil.h
trunk/mapserver/maphttp.c
trunk/mapserver/mapows.h
trunk/mapserver/mapserv.c
trunk/mapserver/mapwfslayer.c
trunk/mapserver/mapwmslayer.c
trunk/mapserver/rfc/ms-rfc-42.txt
Log:
RFC-42 HTTP Cookie Forward Initial Revision (#2566)
Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT 2008-04-01 18:45:53 UTC (rev 7490)
+++ trunk/mapserver/HISTORY.TXT 2008-04-01 21:34:39 UTC (rev 7491)
@@ -13,6 +13,8 @@
Current Version (5.1-dev, SVN trunk):
-------------------------------------
+- RFC-42 HTTP Cookie Forwarding (#2566)
+
- Fixed handling of encrypted connection strings in postgis driver (#2563)
- mapagg.cpp: AGG: add opacity at the style level (#1155)
Modified: trunk/mapserver/cgiutil.c
===================================================================
--- trunk/mapserver/cgiutil.c 2008-04-01 18:45:53 UTC (rev 7490)
+++ trunk/mapserver/cgiutil.c 2008-04-01 21:34:39 UTC (rev 7491)
@@ -1,5 +1,5 @@
/******************************************************************************
- * $Id:$
+ * $Id$
*
* Project: MapServer
* Purpose: cgiRequestObj and CGI parameter parsing.
@@ -202,7 +202,8 @@
/* check for any available cookies */
s = getenv("HTTP_COOKIE");
- if(s != NULL) {
+ if(s != NULL) {
+ request->httpcookiedata = strdup(s);
for(x=0;s[0] != '\0';x++) {
if(m >= MS_MAX_CGI_PARAMS) {
msIO_printf("Too many name/value pairs, aborting.\n");
@@ -396,6 +397,7 @@
request->type = -1;
request->contenttype = NULL;
request->postrequest = NULL;
+ request->httpcookiedata = NULL;
return request;
}
@@ -409,8 +411,10 @@
request->type = -1;
msFree(request->contenttype);
msFree(request->postrequest);
+ msFree(request->httpcookiedata);
request->contenttype = NULL;
request->postrequest = NULL;
+ request->httpcookiedata = NULL;
msFree(request);
}
Modified: trunk/mapserver/cgiutil.h
===================================================================
--- trunk/mapserver/cgiutil.h 2008-04-01 18:45:53 UTC (rev 7490)
+++ trunk/mapserver/cgiutil.h 2008-04-01 21:34:39 UTC (rev 7491)
@@ -63,6 +63,8 @@
char *contenttype;
char *postrequest;
+
+ char *httpcookiedata;
} cgiRequestObj;
Modified: trunk/mapserver/maphttp.c
===================================================================
--- trunk/mapserver/maphttp.c 2008-04-01 18:45:53 UTC (rev 7490)
+++ trunk/mapserver/maphttp.c 2008-04-01 21:34:39 UTC (rev 7491)
@@ -136,6 +136,7 @@
pasReqInfo[i].pszContentType = NULL;
pasReqInfo[i].pszErrBuf = NULL;
pasReqInfo[i].pszUserAgent = NULL;
+ pasReqInfo[i].pszHTTPCookieData = NULL;
pasReqInfo[i].debug = MS_FALSE;
@@ -183,6 +184,10 @@
free(pasReqInfo[i].pszUserAgent);
pasReqInfo[i].pszUserAgent = NULL;
+ if (pasReqInfo[i].pszHTTPCookieData)
+ free(pasReqInfo[i].pszHTTPCookieData);
+ pasReqInfo[i].pszHTTPCookieData = NULL;
+
pasReqInfo[i].curl_handle = NULL;
}
}
@@ -405,6 +410,29 @@
curl_easy_setopt(http_handle, CURLOPT_HTTPHEADER, headers);
/* curl_slist_free_all(headers); */ /* free the header list */
}
+
+ /* Added by RFC-42 HTTP Cookie Forwarding */
+ if(pasReqInfo[i].pszHTTPCookieData != NULL)
+ {
+ /* Check if there's no end of line in the Cookie string */
+ /* This could break the HTTP Header */
+ int nPos;
+
+ for(nPos=0; nPos<strlen(pasReqInfo[i].pszHTTPCookieData); nPos++)
+ {
+ if(pasReqInfo[i].pszHTTPCookieData[nPos] == '\n')
+ {
+ msSetError(MS_HTTPERR, "Can't open output file %s.",
+ "msHTTPExecuteRequests()", pasReqInfo[i].pszOutputFile);
+ return(MS_FAILURE);
+ }
+ }
+
+ // Set the Curl option to send Cookie
+ curl_easy_setopt(http_handle, CURLOPT_COOKIE,
+ pasReqInfo[i].pszHTTPCookieData);
+ }
+
/* Add to multi handle */
curl_multi_add_handle(multi_handle, http_handle);
Modified: trunk/mapserver/mapows.h
===================================================================
--- trunk/mapserver/mapows.h 2008-04-01 18:45:53 UTC (rev 7490)
+++ trunk/mapserver/mapows.h 2008-04-01 21:34:39 UTC (rev 7491)
@@ -35,6 +35,7 @@
char *pszPostRequest; /* post request content (NULL for GET) */
char *pszPostContentType;/* post request MIME type */
char *pszUserAgent; /* User-Agent, auto-generated if not set */
+ char *pszHTTPCookieData; /* HTTP Cookie data */
/* For debugging/profiling */
int debug; /* Debug mode? MS_TRUE/MS_FALSE */
@@ -96,6 +97,7 @@
char *onlineresource;
hashTableObj *params;
int numparams;
+ char *httpcookiedata;
} wmsParamsObj;
int msHTTPInit(void);
Modified: trunk/mapserver/mapserv.c
===================================================================
--- trunk/mapserver/mapserv.c 2008-04-01 18:45:53 UTC (rev 7490)
+++ trunk/mapserver/mapserv.c 2008-04-01 21:34:39 UTC (rev 7491)
@@ -1148,6 +1148,21 @@
#endif
/*
+ * RFC-42 HTTP Cookie Forwarding
+ * Here we set the http_cookie_data metadata to handle the
+ * HTTP Cookie Forwarding. The content of this metadata is the cookie
+ * content. In the future, this metadata will probably be replaced
+ * by an object that is part of the mapObject that would contain
+ * information on the application status (such as cookie).
+ */
+ if( msObj->request->httpcookiedata != NULL &&
+ msOWSLookupMetadata(&(msObj->Map->web.metadata), "OMF", "http_cookie"))
+ {
+ msInsertHashTable( &(msObj->Map->web.metadata), "http_cookie_data",
+ msObj->request->httpcookiedata );
+ }
+
+ /*
** Start by calling the WMS/WFS/WCS Dispatchers. If they fail then we'll
** process this as a regular MapServer request.
*/
Modified: trunk/mapserver/mapwfslayer.c
===================================================================
--- trunk/mapserver/mapwfslayer.c 2008-04-01 18:45:53 UTC (rev 7490)
+++ trunk/mapserver/mapwfslayer.c 2008-04-01 21:34:39 UTC (rev 7491)
@@ -1,5 +1,5 @@
/**********************************************************************
- * $Id:$
+ * $Id$
*
* Project: MapServer
* Purpose: Implementation of WFS CONNECTIONTYPE - client to WFS servers
@@ -517,6 +517,7 @@
char *pszHashFileName = NULL;
int bPostRequest = 0;
wfsParamsObj *psParams = NULL;
+ char *pszHTTPCookieData = NULL;
if (lp->connectiontype != MS_WFS || lp->connection == NULL)
@@ -576,6 +577,44 @@
nTimeout = atoi(pszTmp);
}
+/*------------------------------------------------------------------
+ * Check to see if there's a HTTP Cookie to forward
+ * If Cookie differ between the two connection, it's NOT OK to merge
+ * the connection
+ * ------------------------------------------------------------------ */
+ if ((pszTmp = msOWSLookupMetadata(&(lp->metadata),
+ "MO", "http_cookie")) != NULL)
+ {
+ if(strcasecmp(pszTmp, "forward") == 0)
+ {
+ pszTmp= msLookupHashTable(&(map->web.metadata),"http_cookie_data");
+ if(pszTmp != NULL)
+ {
+ pszHTTPCookieData = strdup(pszTmp);
+ }
+ }
+ else
+ {
+ pszHTTPCookieData = strdup(pszTmp);
+ }
+ }
+ else if ((pszTmp = msOWSLookupMetadata(&(map->web.metadata),
+ "MO", "http_cookie")) != NULL)
+ {
+ if(strcasecmp(pszTmp, "forward") == 0)
+ {
+ pszTmp= msLookupHashTable(&(map->web.metadata),"http_cookie_data");
+ if(pszTmp != NULL)
+ {
+ pszHTTPCookieData = strdup(pszTmp);
+ }
+ }
+ else
+ {
+ pszHTTPCookieData = strdup(pszTmp);
+ }
+ }
+
/* ------------------------------------------------------------------
* If nLayerId == -1 then we need to figure it
* ------------------------------------------------------------------ */
@@ -624,6 +663,8 @@
msOWSBuildURLFilename(map->web.imagepath,
pszHashFileName,".tmp.gml");
free(pszHashFileName);
+ pasReqInfo[(*numRequests)].pszHTTPCookieData = pszHTTPCookieData;
+ pszHTTPCookieData = NULL;
pasReqInfo[(*numRequests)].nStatus = 0;
pasReqInfo[(*numRequests)].nTimeout = nTimeout;
pasReqInfo[(*numRequests)].bbox = bbox;
Modified: trunk/mapserver/mapwmslayer.c
===================================================================
--- trunk/mapserver/mapwmslayer.c 2008-04-01 18:45:53 UTC (rev 7490)
+++ trunk/mapserver/mapwmslayer.c 2008-04-01 21:34:39 UTC (rev 7491)
@@ -49,6 +49,7 @@
wmsparams->onlineresource = NULL;
wmsparams->params = msCreateHashTable();
wmsparams->numparams=0;
+ wmsparams->httpcookiedata = NULL;
return MS_SUCCESS;
}
@@ -66,6 +67,8 @@
msFreeHashTable(wmsparams->params);
wmsparams->params = NULL;
+ msFree(wmsparams->httpcookiedata);
+
wmsparams->numparams=0;
}
@@ -762,7 +765,7 @@
httpRequestObj *pasReqInfo, int *numRequests)
{
#ifdef USE_WMS_LYR
- char *pszURL = NULL;
+ char *pszURL = NULL, *pszHTTPCookieData = NULL;
const char *pszTmp;
rectObj bbox;
int nTimeout, bOkToMerge, bForceSeparateRequest;
@@ -885,6 +888,56 @@
}
}
+/*------------------------------------------------------------------
+ * Check to see if there's a HTTP Cookie to forward
+ * If Cookie differ between the two connection, it's NOT OK to merge
+ * the connection
+ * ------------------------------------------------------------------ */
+ if ((pszTmp = msOWSLookupMetadata(&(lp->metadata),
+ "MO", "http_cookie")) != NULL)
+ {
+ if(strcasecmp(pszTmp, "forward") == 0)
+ {
+ pszTmp= msLookupHashTable(&(map->web.metadata),"http_cookie_data");
+ if(pszTmp != NULL)
+ {
+ pszHTTPCookieData = strdup(pszTmp);
+ }
+ }
+ else
+ {
+ pszHTTPCookieData = strdup(pszTmp);
+ }
+ }
+ else if ((pszTmp = msOWSLookupMetadata(&(map->web.metadata),
+ "MO", "http_cookie")) != NULL)
+ {
+ if(strcasecmp(pszTmp, "forward") == 0)
+ {
+ pszTmp= msLookupHashTable(&(map->web.metadata),"http_cookie_data");
+ if(pszTmp != NULL)
+ {
+ pszHTTPCookieData = strdup(pszTmp);
+ }
+ }
+ else
+ {
+ pszHTTPCookieData = strdup(pszTmp);
+ }
+ }
+
+ if(bOkToMerge && pszHTTPCookieData != sThisWMSParams.httpcookiedata)
+ {
+ if(pszHTTPCookieData == NULL || sThisWMSParams.httpcookiedata == NULL)
+ {
+ bOkToMerge = MS_FALSE;
+ }
+ if(strcmp(pszHTTPCookieData, sThisWMSParams.httpcookiedata) != 0)
+ {
+ bOkToMerge = MS_FALSE;
+ }
+ }
+
if (bOkToMerge)
{
/* Merge both requests into sThisWMSParams
@@ -956,6 +1009,8 @@
"msPrepareWMSLayerRequest()");
return MS_FAILURE;
}
+ pasReqInfo[(*numRequests)].pszHTTPCookieData = pszHTTPCookieData;
+ pszHTTPCookieData = NULL;
pasReqInfo[(*numRequests)].pszOutputFile =msTmpFile(map->mappath,
map->web.imagepath,
"img.tmp");
Modified: trunk/mapserver/rfc/ms-rfc-42.txt
===================================================================
--- trunk/mapserver/rfc/ms-rfc-42.txt 2008-04-01 18:45:53 UTC (rev 7490)
+++ trunk/mapserver/rfc/ms-rfc-42.txt 2008-04-01 21:34:39 UTC (rev 7491)
@@ -118,13 +118,13 @@
Bug ID
==============================================================================
-None Yet.
+http://trac.osgeo.org/mapserver/ticket/2566
==============================================================================
Voting History
==============================================================================
-None Yet.
+Adopted on 2008/04/01 with +1 from FrankW, DanielM, TomK and AssefaY, and +0 from JeffM and PericlesN.
More information about the mapserver-commits
mailing list