[mapserver-commits] r7411 - trunk/mapserver
svn at osgeo.org
svn at osgeo.org
Wed Feb 27 10:35:10 EST 2008
Author: dmorissette
Date: 2008-02-27 10:35:10 -0500 (Wed, 27 Feb 2008)
New Revision: 7411
Modified:
trunk/mapserver/mapcontext.c
trunk/mapserver/mapows.c
trunk/mapserver/mapows.h
trunk/mapserver/mapwcs.c
trunk/mapserver/mapwms.c
trunk/mapserver/mapwmslayer.c
Log:
Distinguish between invalid version format and version not being set (#2528)
Modified: trunk/mapserver/mapcontext.c
===================================================================
--- trunk/mapserver/mapcontext.c 2008-02-27 14:54:05 UTC (rev 7410)
+++ trunk/mapserver/mapcontext.c 2008-02-27 15:35:10 UTC (rev 7411)
@@ -1439,7 +1439,7 @@
char * tabspace=NULL, *pszValue, *pszChar,*pszSLD=NULL,*pszURL,*pszSLD2=NULL;
char *pszStyle, *pszCurrent, *pszStyleItem, *pszSLDBody;
char *pszEncodedVal;
- int i, nValue, nVersion=-1;
+ int i, nValue, nVersion=OWS_VERSION_NOTSET;
/* Dimension element */
char *pszDimension;
const char *pszDimUserValue=NULL, *pszDimUnits=NULL, *pszDimDefault=NULL;
@@ -1453,7 +1453,7 @@
version = "1.1.0";
nVersion = msOWSParseVersionString(version);
- if (nVersion < 0)
+ if (nVersion == OWS_VERSION_BADFORMAT)
return MS_FAILURE; /* msSetError() already called. */
/* Make sure this is a supported version */
Modified: trunk/mapserver/mapows.c
===================================================================
--- trunk/mapserver/mapows.c 2008-02-27 14:54:05 UTC (rev 7410)
+++ trunk/mapserver/mapows.c 2008-02-27 15:35:10 UTC (rev 7411)
@@ -380,7 +380,8 @@
** Parse a version string in the format "a.b.c" or "a.b" and return an
** integer in the format 0x0a0b0c suitable for regular integer comparisons.
**
-** Returns -1 if version could not be parsed.
+** Returns one of OWS_VERSION_NOTSET or OWS_VERSION_BADFORMAT if version
+** could not be parsed.
*/
int msOWSParseVersionString(const char *pszVersion)
{
@@ -399,7 +400,7 @@
"msOWSParseVersionString()", pszVersion);
if (digits)
msFreeCharArray(digits, numDigits);
- return -1;
+ return OWS_VERSION_BADFORMAT;
}
nVersion = atoi(digits[0])*0x010000;
@@ -412,7 +413,7 @@
return nVersion;
}
- return -1;
+ return OWS_VERSION_NOTSET;
}
/* msOWSGetVersionString()
Modified: trunk/mapserver/mapows.h
===================================================================
--- trunk/mapserver/mapows.h 2008-02-27 14:54:05 UTC (rev 7410)
+++ trunk/mapserver/mapows.h 2008-02-27 15:35:10 UTC (rev 7411)
@@ -137,6 +137,8 @@
#define OWS_1_1_0 0x010100
#define OWS_1_1_1 0x010101
#define OWS_VERSION_MAXLEN 20 /* Buffer size for msOWSGetVersionString() */
+#define OWS_VERSION_NOTSET -1
+#define OWS_VERSION_BADFORMAT -2
MS_DLL_EXPORT int msOWSParseVersionString(const char *pszVersion);
MS_DLL_EXPORT const char *msOWSGetVersionString(int nVersion, char *pszBuffer);
Modified: trunk/mapserver/mapwcs.c
===================================================================
--- trunk/mapserver/mapwcs.c 2008-02-27 14:54:05 UTC (rev 7410)
+++ trunk/mapserver/mapwcs.c 2008-02-27 15:35:10 UTC (rev 7411)
@@ -100,8 +100,7 @@
if( version == NULL )
version = "1.0.0";
- if( msOWSParseVersionString(version) >=
- msOWSParseVersionString("1.1.0") )
+ if( msOWSParseVersionString(version) >= OWS_1_1_0 )
return msWCSException11( map, code, locator, version );
msIO_printf("Content-type: application/vnd.ogc.se_xml%c%c",10,10);
Modified: trunk/mapserver/mapwms.c
===================================================================
--- trunk/mapserver/mapwms.c 2008-02-27 14:54:05 UTC (rev 7410)
+++ trunk/mapserver/mapwms.c 2008-02-27 15:35:10 UTC (rev 7411)
@@ -2908,7 +2908,7 @@
int msWMSDispatch(mapObj *map, cgiRequestObj *req)
{
#ifdef USE_WMS_SVR
- int i, status, nVersion=-1;
+ int i, status, nVersion=OWS_VERSION_NOTSET;
const char *version=NULL, *request=NULL, *service=NULL, *format=NULL, *updatesequence=NULL;
/*
@@ -2941,6 +2941,13 @@
return MS_DONE; /* Not a WMS request */
nVersion = msOWSParseVersionString(version);
+ if (nVersion == OWS_VERSION_BADFORMAT)
+ {
+ /* Invalid version format. msSetError() has been called by
+ * msOWSParseVersionString() and we return the error as an exception
+ */
+ return msWMSException(map, OWS_VERSION_NOTSET, NULL);
+ }
/*
** GetCapbilities request needs the service parametr defined as WMS:
@@ -2949,7 +2956,7 @@
if (request && service == NULL &&
(strcasecmp(request, "capabilities") == 0 ||
strcasecmp(request, "GetCapabilities") == 0) &&
- (nVersion >= OWS_1_0_7 || nVersion == -1))
+ (nVersion >= OWS_1_0_7 || nVersion == OWS_VERSION_NOTSET))
{
msSetError(MS_WMSERR, "Required SERVICE parameter missing.", "msWMSDispatch");
return msWMSException(map, nVersion, "ServiceNotDefined");
@@ -2962,7 +2969,7 @@
if (request && (strcasecmp(request, "capabilities") == 0 ||
strcasecmp(request, "GetCapabilities") == 0) )
{
- if (nVersion == -1)
+ if (nVersion == OWS_VERSION_NOTSET)
nVersion = OWS_1_1_1;/* VERSION is optional with getCapabilities only */
if ((status = msOWSMakeAllLayersUnique(map)) != MS_SUCCESS)
return msWMSException(map, nVersion, NULL);
@@ -2980,7 +2987,7 @@
getcontext_enabled = msOWSLookupMetadata(&(map->web.metadata),
"MO", "getcontext_enabled");
- if (nVersion != -1)
+ if (nVersion != OWS_VERSION_NOTSET)
{
/* VERSION, if specified, is Map Context version, not WMS version */
/* Pass it via wms_context_version metadata */
@@ -3033,16 +3040,16 @@
}
/* If SERVICE, VERSION and REQUEST not included than this isn't a WMS req*/
- if (service == NULL && nVersion == -1 && request==NULL)
+ if (service == NULL && nVersion == OWS_VERSION_NOTSET && request==NULL)
return MS_DONE; /* Not a WMS request */
/* VERSION *and* REQUEST required by both getMap and getFeatureInfo */
- if (nVersion == -1)
+ if (nVersion == OWS_VERSION_NOTSET)
{
msSetError(MS_WMSERR,
"Incomplete WMS request: VERSION parameter missing",
"msWMSDispatch()");
- return msWMSException(map, nVersion, NULL);
+ return msWMSException(map, OWS_VERSION_NOTSET, NULL);
}
if (request==NULL)
Modified: trunk/mapserver/mapwmslayer.c
===================================================================
--- trunk/mapserver/mapwmslayer.c 2008-02-27 14:54:05 UTC (rev 7410)
+++ trunk/mapserver/mapwmslayer.c 2008-02-27 15:35:10 UTC (rev 7411)
@@ -425,7 +425,7 @@
char *pszEPSG = NULL;
const char *pszVersion, *pszTmp, *pszRequestParam, *pszExceptionsParam;
rectObj bbox;
- int nVersion=0;
+ int nVersion=OWS_VERSION_NOTSET;
if (lp->connectiontype != MS_WMS)
{
More information about the mapserver-commits
mailing list