[mapserver-commits] r10868 - branches/branch-5-6/mapserver

svn at osgeo.org svn at osgeo.org
Fri Jan 14 10:08:26 EST 2011


Author: assefa
Date: 2011-01-14 07:08:26 -0800 (Fri, 14 Jan 2011)
New Revision: 10868

Modified:
   branches/branch-5-6/mapserver/HISTORY.TXT
   branches/branch-5-6/mapserver/mapobject.c
   branches/branch-5-6/mapserver/mapows.h
   branches/branch-5-6/mapserver/mapwms.c
Log:
Fix WMS EXCEPTIONS parameter issue with fastcgi (#3525)

Modified: branches/branch-5-6/mapserver/HISTORY.TXT
===================================================================
--- branches/branch-5-6/mapserver/HISTORY.TXT	2011-01-14 14:56:21 UTC (rev 10867)
+++ branches/branch-5-6/mapserver/HISTORY.TXT	2011-01-14 15:08:26 UTC (rev 10868)
@@ -17,6 +17,8 @@
 Version 5.6.6 (SVN branch-5-6):
 -------------------------------
 
+- Fix WMS EXCEPTIONS parameter issue with fastcgi (#3525)
+
 - Fixed missing time in msDrawMap logging (#3651)
 
 - Fixed Internal error with Oracle Spatial multi point geometries (#3627)

Modified: branches/branch-5-6/mapserver/mapobject.c
===================================================================
--- branches/branch-5-6/mapserver/mapobject.c	2011-01-14 14:56:21 UTC (rev 10867)
+++ branches/branch-5-6/mapserver/mapobject.c	2011-01-14 15:08:26 UTC (rev 10868)
@@ -774,10 +774,17 @@
 {
 #ifdef USE_WMS_SVR
     int version;
+    char *wms_exception_format = NULL;
+    int i =0;
 
     version = msOWSParseVersionString(wmtver);
+    for(i=0; i<request->NumParams; i++) 
+    {
+         if (strcasecmp(request->ParamNames[i], "EXCEPTIONS") == 0)
+           wms_exception_format = request->ParamValues[i];
+    }
     return msWMSLoadGetMapParams(map, version, request->ParamNames,
-                                 request->ParamValues, request->NumParams);
+                                 request->ParamValues, request->NumParams,  wms_exception_format);
 #else
     msSetError(MS_WMSERR, "WMS server support is not available.",
                "msMapLoadOWSParameters()");

Modified: branches/branch-5-6/mapserver/mapows.h
===================================================================
--- branches/branch-5-6/mapserver/mapows.h	2011-01-14 14:56:21 UTC (rev 10867)
+++ branches/branch-5-6/mapserver/mapows.h	2011-01-14 15:08:26 UTC (rev 10868)
@@ -408,8 +408,8 @@
  *   mapwms.c
  *====================================================================*/
 int msWMSDispatch(mapObj *map, cgiRequestObj *req); 
-MS_DLL_EXPORT int msWMSLoadGetMapParams(mapObj *map, int nVersion,
-                          char **names, char **values, int numentries);
+MS_DLL_EXPORT int msWMSLoadGetMapParams(mapObj *map, int nVersion, char **names, 
+                                        char **values, int numentries, char *wms_exception_format);
 
 
 /*====================================================================

Modified: branches/branch-5-6/mapserver/mapwms.c
===================================================================
--- branches/branch-5-6/mapserver/mapwms.c	2011-01-14 14:56:21 UTC (rev 10867)
+++ branches/branch-5-6/mapserver/mapwms.c	2011-01-14 15:08:26 UTC (rev 10868)
@@ -65,9 +65,8 @@
 **
 ** Report current MapServer error in requested format.
 */
-static char *wms_exception_format=NULL;
 
-int msWMSException(mapObj *map, int nVersion, const char *exception_code)
+int msWMSException(mapObj *map, int nVersion, const char *exception_code,  char *wms_exception_format)
 {
     const char *encoding;
     char *schemalocation = NULL;
@@ -282,7 +281,7 @@
 /*
 ** Apply the TIME parameter to layers that are time aware
 */
-int msWMSApplyTime(mapObj *map, int version, char *time)
+int msWMSApplyTime(mapObj *map, int version, char *time, char *wms_exception_format)
 {
     int i=0;
     layerObj *lp = NULL;
@@ -313,7 +312,7 @@
                     {
                         msSetError(MS_WMSERR, "No Time value was given, and no default time value defined.", "msWMSApplyTime");
                         return msWMSException(map, version,
-                                              "MissingDimensionValue");
+                                              "MissingDimensionValue", wms_exception_format);
                     }
                     else
                     {
@@ -322,7 +321,7 @@
                             msSetError(MS_WMSERR, "No Time value was given, and the default time value %s is invalid or outside the time extent defined %s", "msWMSApplyTime", timedefault, timeextent);
                         /* return MS_FALSE; */
                             return msWMSException(map, version,
-                                              "InvalidDimensionValue");
+                                                  "InvalidDimensionValue", wms_exception_format);
                         }
                         msLayerSetTimeFilter(lp, timedefault, timefield);
                     }
@@ -337,7 +336,7 @@
                             msSetError(MS_WMSERR, "Time value(s) %s given is invalid or outside the time extent defined (%s).", "msWMSApplyTime", time, timeextent);
                         /* return MS_FALSE; */
                             return msWMSException(map, version,
-                                                  "InvalidDimensionValue");
+                                                  "InvalidDimensionValue", wms_exception_format);
                         }
                         else
                         {
@@ -346,7 +345,7 @@
                                 msSetError(MS_WMSERR, "Time value(s) %s given is invalid or outside the time extent defined (%s), and default time set is invalid (%s)", "msWMSApplyTime", time, timeextent, timedefault);
                         /* return MS_FALSE; */
                                 return msWMSException(map, version,
-                                                      "InvalidDimensionValue");
+                                                      "InvalidDimensionValue", wms_exception_format);
                             }
                             else
                               msLayerSetTimeFilter(lp, timedefault, timefield);
@@ -380,7 +379,7 @@
 **
 */
 int msWMSLoadGetMapParams(mapObj *map, int nVersion,
-                          char **names, char **values, int numentries)
+                          char **names, char **values, int numentries, char *wms_exception_format)
 {
   int i, adjust_extent = MS_FALSE, nonsquare_enabled = MS_FALSE;
   int iUnits = -1;
@@ -443,7 +442,7 @@
        if (ogrEnabled == 0)
        {
           msSetError(MS_WMSERR, "OGR support is not available.", "msWMSLoadGetMapParams()");
-          return msWMSException(map, nVersion, NULL);
+          return msWMSException(map, nVersion, NULL, wms_exception_format);
        }
        else
        {
@@ -452,12 +451,12 @@
             if (strcasecmp(names[i], "SLD") == 0)
             {
               if ((status = msSLDApplySLDURL(map, values[i], -1, NULL)) != MS_SUCCESS)
-                return msWMSException(map, nVersion, NULL);
+                return msWMSException(map, nVersion, NULL, wms_exception_format);
             }
             if (strcasecmp(names[i], "SLD_BODY") == 0)
             {
               if ((status =msSLDApplySLD(map, values[i], -1, NULL)) != MS_SUCCESS)
-                return msWMSException(map, nVersion, NULL);
+                return msWMSException(map, nVersion, NULL, wms_exception_format);
             }
           }
        }
@@ -478,7 +477,7 @@
       if (layers==NULL || strlen(values[i]) <=0 ||   numlayers < 1) {
         msSetError(MS_WMSERR, "At least one layer name required in LAYERS.",
                    "msWMSLoadGetMapParams()");
-        return msWMSException(map, nVersion, NULL);
+        return msWMSException(map, nVersion, NULL, wms_exception_format);
       }
 
 
@@ -609,14 +608,14 @@
               msSetError(MS_WMSERR,
                          "Unsupported CRS namespace (only EPSG, AUTO2, CRS currently supported).",
                          "msWMSLoadGetMapParams()");
-              return msWMSException(map, nVersion, "InvalidCRS");
+              return msWMSException(map, nVersion, "InvalidCRS", wms_exception_format);
           }
           else
           {
               msSetError(MS_WMSERR,
                          "Unsupported SRS namespace (only EPSG and AUTO currently supported).",
                          "msWMSLoadGetMapParams()");
-              return msWMSException(map, nVersion, "InvalidSRS");
+              return msWMSException(map, nVersion, "InvalidSRS", wms_exception_format);
           }
       }
     }
@@ -628,7 +627,7 @@
       if (tokens==NULL || n != 4) {
         msSetError(MS_WMSERR, "Wrong number of arguments for BBOX.",
                    "msWMSLoadGetMapParams()");
-        return msWMSException(map, nVersion, NULL);
+        return msWMSException(map, nVersion, NULL, wms_exception_format);
       }
       bboxrequest = values[i];
 
@@ -650,7 +649,7 @@
               msSetError(MS_WMSERR,
                          "Invalid values for BBOX.",
                          "msWMSLoadGetMapParams()");
-              return msWMSException(map, nVersion, NULL);
+              return msWMSException(map, nVersion, NULL, wms_exception_format);
           }
           adjust_extent = MS_TRUE;
       }
@@ -689,7 +688,7 @@
                        "Unsupported output format (%s).",
                        "msWMSLoadGetMapParams()",
                        values[i] );
-            return msWMSException(map, nVersion, "InvalidFormat");
+            return msWMSException(map, nVersion, "InvalidFormat", wms_exception_format);
           }
       }
       else
@@ -705,7 +704,7 @@
                          "Unsupported output format (%s).",
                          "msWMSLoadGetMapParams()",
                          values[i] );
-              return msWMSException(map, nVersion, "InvalidFormat");
+              return msWMSException(map, nVersion, "InvalidFormat", wms_exception_format);
           }
       }
       msFree( map->imagetype );
@@ -740,9 +739,9 @@
            strcasecmp(wms_exception_format, "XML") != 0)
        {
            msSetError(MS_WMSERR,
-                      "Invalid format for the EXCEPTION parameter.",
+                      "Invalid format for the EXCEPTIONS parameter.",
                       "msWMSLoadGetMapParams()");
-           return msWMSException(map, nVersion, "InvalidFormat");
+           return msWMSException(map, nVersion, "InvalidFormat", wms_exception_format);
        }
    }
    if (bboxfound && bboxrequest && nVersion >= OWS_1_3_0)
@@ -807,7 +806,7 @@
            msSetError(MS_WMSERR,
                       "Invalid values for BBOX.",
                       "msWMSLoadGetMapParams()");
-           return msWMSException(map, nVersion, NULL);
+           return msWMSException(map, nVersion, NULL, wms_exception_format);
        }
        adjust_extent = MS_TRUE;
    }
@@ -836,7 +835,7 @@
   */
   if (timerequest)
   {
-      if (msWMSApplyTime(map, nVersion, stime) == MS_FAILURE)
+    if (msWMSApplyTime(map, nVersion, stime, wms_exception_format) == MS_FAILURE)
       {
           return MS_FAILURE;/* msWMSException(map, nVersion, "InvalidTimeRequest"); */
       }
@@ -857,7 +856,7 @@
   {
       msSetError(MS_WMSERR, "Invalid layer(s) given in the LAYERS parameter.",
                  "msWMSLoadGetMapParams()");
-      return msWMSException(map, nVersion, "LayerNotDefined");
+      return msWMSException(map, nVersion, "LayerNotDefined", wms_exception_format);
   }
 
   /* validate srs value: When the SRS parameter in a GetMap request contains a
@@ -919,13 +918,13 @@
                       {
                           msSetError(MS_WMSERR, "Invalid CRS given : CRS must be valid for all requested layers.",
                                      "msWMSLoadGetMapParams()");
-                          return msWMSException(map, nVersion, "InvalidSRS");
+                          return msWMSException(map, nVersion, "InvalidSRS", wms_exception_format);
                       }
                       else
                       {
                           msSetError(MS_WMSERR, "Invalid SRS given : SRS must be valid for all requested layers.",
                                      "msWMSLoadGetMapParams()");
-                          return msWMSException(map, nVersion, "InvalidSRS");
+                          return msWMSException(map, nVersion, "InvalidSRS", wms_exception_format);
                       }
                   }
               }
@@ -943,7 +942,7 @@
       /* Restore valid default values in case errors INIMAGE are used */
       map->width = 400;
       map->height= 300;
-      return msWMSException(map, nVersion, NULL);
+      return msWMSException(map, nVersion, NULL, wms_exception_format);
   }
 
   /* Check whether requested BBOX and width/height result in non-square pixels
@@ -986,7 +985,7 @@
                          "have any projection set. Please make sure your mapfile "
                          "has a projection defined at the top level.", 
                          "msWMSLoadGetMapParams()");
-              return msWMSException(map, nVersion, "InvalidCRS");
+              return msWMSException(map, nVersion, "InvalidCRS", wms_exception_format);
           }
           else
           {
@@ -994,7 +993,7 @@
                          "have any projection set. Please make sure your mapfile "
                          "has a projection defined at the top level.", 
                          "msWMSLoadGetMapParams()");
-              return msWMSException(map, nVersion, "InvalidSRS");
+               return msWMSException(map, nVersion, "InvalidSRS", wms_exception_format);
           }
       }
       
@@ -1010,7 +1009,7 @@
           if (nTmp != 0)
           { 
               msFreeProjection(&newProj);
-              return msWMSException(map, nVersion, NULL);
+              return msWMSException(map, nVersion, NULL, wms_exception_format);
           }
       }
 
@@ -1035,7 +1034,7 @@
                                              original_srs) != 0)
                   {
                       msFreeProjection(&newProj);
-                      return msWMSException(map, nVersion, NULL);
+                      return msWMSException(map, nVersion, NULL, wms_exception_format);
                   }
                   GET_LAYER(map, i)->project = MS_TRUE;
               }
@@ -1060,7 +1059,7 @@
         nTmp = msLoadProjectionString(&(map->projection), srsbuffer);
 
       if (nTmp != 0)
-        return msWMSException(map, nVersion, NULL);
+        return msWMSException(map, nVersion, NULL, wms_exception_format);
 
       iUnits = GetMapserverUnitUsingProj(&(map->projection));
       if (iUnits != -1)
@@ -1125,7 +1124,7 @@
                               msFreeCharArray(tokens, n);
                               msFreeCharArray(layers, numlayers);
                               
-                              return msWMSException(map, nVersion, "StyleNotDefined");
+                              return msWMSException(map, nVersion, "StyleNotDefined", wms_exception_format);
                           }
                       }
                                      
@@ -1139,7 +1138,7 @@
                     msFreeCharArray(tokens, n);
                   if (layers && numlayers > 0)
                     msFreeCharArray(layers, numlayers);
-                  return msWMSException(map, nVersion, "StyleNotDefined");
+                  return msWMSException(map, nVersion, "StyleNotDefined", wms_exception_format);
               }
           }
       }
@@ -1174,31 +1173,31 @@
       else
         msSetError(MS_WMSERR, "Missing required parameter SRS", "msWMSLoadGetMapParams()");
 
-      return msWMSException(map, nVersion, "MissingParameterValue");
+      return msWMSException(map, nVersion, "MissingParameterValue", wms_exception_format);
     }
 
     if (bboxfound == 0)
     {
       msSetError(MS_WMSERR, "Missing required parameter BBOX", "msWMSLoadGetMapParams()");
-      return msWMSException(map, nVersion, "MissingParameterValue");
+      return msWMSException(map, nVersion, "MissingParameterValue", wms_exception_format);
     }  
 
     if (formatfound == 0 && (strcasecmp(request, "GetMap") == 0 || strcasecmp(request, "map") == 0))
     {
       msSetError(MS_WMSERR, "Missing required parameter FORMAT", "msWMSLoadGetMapParams()");
-      return msWMSException(map, nVersion, "MissingParameterValue");
+      return msWMSException(map, nVersion, "MissingParameterValue", wms_exception_format);
     }
 
     if (widthfound == 0)
     {
       msSetError(MS_WMSERR, "Missing required parameter WIDTH", "msWMSLoadGetMapParams()");
-      return msWMSException(map, nVersion, "MissingParameterValue");
+      return msWMSException(map, nVersion, "MissingParameterValue", wms_exception_format);
     }
 
     if (heightfound == 0)
     {
       msSetError(MS_WMSERR, "Missing required parameter HEIGHT", "msWMSLoadGetMapParams()");
-      return msWMSException(map, nVersion, "MissingParameterValue");
+      return msWMSException(map, nVersion, "MissingParameterValue", wms_exception_format);
     }
   
   }
@@ -1935,7 +1934,8 @@
 /*
 ** msWMSGetCapabilities()
 */
-int msWMSGetCapabilities(mapObj *map, int nVersion, cgiRequestObj *req, const char *requested_updatesequence)
+int msWMSGetCapabilities(mapObj *map, int nVersion, cgiRequestObj *req, const char *requested_updatesequence,
+                         char *wms_exception_format)
 {
   char *dtd_url = NULL;
   char *script_url=NULL, *script_url_encoded=NULL;
@@ -1961,11 +1961,11 @@
       i = msOWSNegotiateUpdateSequence(requested_updatesequence, updatesequence);
       if (i == 0) { /* current */
           msSetError(MS_WMSERR, "UPDATESEQUENCE parameter (%s) is equal to server (%s)", "msWMSGetCapabilities()", requested_updatesequence, updatesequence);
-          return msWMSException(map, nVersion, "CurrentUpdateSequence");
+          return msWMSException(map, nVersion, "CurrentUpdateSequence", wms_exception_format);
       }
       if (i > 0) { /* invalid */
           msSetError(MS_WMSERR, "UPDATESEQUENCE parameter (%s) is higher than server (%s)", "msWMSGetCapabilities()", requested_updatesequence, updatesequence);
-          return msWMSException(map, nVersion, "InvalidUpdateSequence");
+          return msWMSException(map, nVersion, "InvalidUpdateSequence", wms_exception_format);
       }
   }
 
@@ -2009,7 +2009,7 @@
   if ((script_url=msOWSGetOnlineResource(map, "MO", "onlineresource", req)) == NULL ||
       (script_url_encoded = msEncodeHTMLEntities(script_url)) == NULL)
   {
-      return msWMSException(map, nVersion, NULL);
+    return msWMSException(map, nVersion, NULL, wms_exception_format);
   }
 
   if (nVersion <= OWS_1_0_7 || nVersion >= OWS_1_3_0)   /* 1.0.0 to 1.0.7 and >=1.3.0*/
@@ -2596,7 +2596,8 @@
 /*
 ** msWMSGetMap()
 */
-int msWMSGetMap(mapObj *map, int nVersion, char **names, char **values, int numentries)
+int msWMSGetMap(mapObj *map, int nVersion, char **names, char **values, int numentries,
+                char *wms_exception_format)
 {
   imageObj *img;
   int i = 0;
@@ -2677,7 +2678,7 @@
   else
     img = msDrawMap(map, MS_FALSE);
   if (img == NULL)
-      return msWMSException(map, nVersion, NULL);
+    return msWMSException(map, nVersion, NULL, wms_exception_format);
   
   /* Set the HTTP Cache-control headers if they are defined
      in the map object */
@@ -2689,7 +2690,7 @@
   msIO_printf("Content-type: %s%c%c",
               MS_IMAGE_MIME_TYPE(map->outputformat), 10,10);
   if (msSaveImage(map, img, NULL) != MS_SUCCESS)
-      return msWMSException(map, nVersion, NULL);
+    return msWMSException(map, nVersion, NULL, wms_exception_format);
 
 
   msFreeImage(img);
@@ -2697,7 +2698,7 @@
   return(MS_SUCCESS);
 }
 
-int msDumpResult(mapObj *map, int bFormatHtml, int nVersion)
+int msDumpResult(mapObj *map, int bFormatHtml, int nVersion, char *wms_exception_format)
 {
    int numresults=0;
    int i;
@@ -2770,7 +2771,7 @@
         if (msLayerResultsGetShape(lp, &shape, lp->resultcache->results[j].tileindex, lp->resultcache->results[j].shapeindex) != MS_SUCCESS)
         {
             msFree(itemvisible);
-            return msWMSException(map, nVersion, NULL);
+            return msWMSException(map, nVersion, NULL, wms_exception_format);
         }
 
         msIO_printf("  Feature %ld: \n", lp->resultcache->results[j].shapeindex);
@@ -2797,7 +2798,8 @@
 /*
 ** msWMSFeatureInfo()
 */
-int msWMSFeatureInfo(mapObj *map, int nVersion, char **names, char **values, int numentries)
+int msWMSFeatureInfo(mapObj *map, int nVersion, char **names, char **values, int numentries,
+                     char *wms_exception_format)
 {
   int i, feature_count=1, numlayers_found=0;
   pointObj point = {-1.0, -1.0};
@@ -2824,7 +2826,7 @@
       layers = msStringSplit(values[i], ',', &numlayers);
       if(layers==NULL || numlayers < 1 || strlen(msStringTrimLeft(values[i])) < 1) {
         msSetError(MS_WMSERR, "At least one layer name required in QUERY_LAYERS.", "msWMSFeatureInfo()");
-        return msWMSException(map, nVersion, "LayerNotDefined");
+        return msWMSException(map, nVersion, "LayerNotDefined", wms_exception_format);
       }
 
       for(j=0; j<map->numlayers; j++) {
@@ -2872,12 +2874,12 @@
       if (query_layer)
       {
           msSetError(MS_WMSERR, "Layer(s) specified in QUERY_LAYERS parameter is not offered by the service instance.", "msWMSFeatureInfo()");
-          return msWMSException(map, nVersion, "LayerNotDefined");
+          return msWMSException(map, nVersion, "LayerNotDefined", wms_exception_format);
       }
       else
       {
           msSetError(MS_WMSERR, "Required QUERY_LAYERS parameter missing for getFeatureInfo.", "msWMSFeatureInfo()");
-          return msWMSException(map, nVersion, "LayerNotDefined");
+          return msWMSException(map, nVersion, "LayerNotDefined", wms_exception_format);
       }
   }
 
@@ -2890,7 +2892,7 @@
       if (GET_LAYER(map, i)->status == MS_ON && !msIsLayerQueryable(GET_LAYER(map, i)))
       {
           msSetError(MS_WMSERR, "Requested layer(s) are not queryable.", "msWMSFeatureInfo()");
-          return msWMSException(map, nVersion, "LayerNotQueryable");
+          return msWMSException(map, nVersion, "LayerNotQueryable", wms_exception_format);
       }
   }
   if(point.x == -1.0 || point.y == -1.0) {
@@ -2898,7 +2900,7 @@
       msSetError(MS_WMSERR, "Required I/J parameters missing for getFeatureInfo.", "msWMSFeatureInfo()");
     else
       msSetError(MS_WMSERR, "Required X/Y parameters missing for getFeatureInfo.", "msWMSFeatureInfo()");
-    return msWMSException(map, nVersion, NULL);
+    return msWMSException(map, nVersion, NULL, wms_exception_format);
   }
 
   /*wms1.3.0: check if the points are valid*/
@@ -2907,7 +2909,7 @@
       if (point.x > map->width || point.y > map->height)
       {
           msSetError(MS_WMSERR, "Invalid I/J values", "msWMSFeatureInfo()");
-          return msWMSException(map, nVersion, "InvalidPoint");
+          return msWMSException(map, nVersion, "InvalidPoint", wms_exception_format);
       }
   }
   /* Perform the actual query */
@@ -2930,7 +2932,7 @@
   map->query.maxresults = feature_count; 
 
   if(msQueryByPoint(map) != MS_SUCCESS)
-      if((query_status=ms_error->code) != MS_NOTFOUND) return msWMSException(map, nVersion, NULL);
+    if((query_status=ms_error->code) != MS_NOTFOUND) return msWMSException(map, nVersion, NULL, wms_exception_format);
 
   /* Generate response */
   if (strcasecmp(info_format, "MIME") == 0 ||
@@ -2945,7 +2947,7 @@
         msIO_printf("Content-type: text/plain%c%c",10,10);
     msIO_printf("GetFeatureInfo results:\n");
 
-    numresults = msDumpResult(map, 0, nVersion);
+    numresults = msDumpResult(map, 0, nVersion, wms_exception_format);
 
     if (numresults == 0) msIO_printf("\n  Search returned no results.\n");
 
@@ -2986,10 +2988,10 @@
      if (query_status == MS_NOTFOUND && msObj->map->web.empty)
      {
          if(msReturnURL(msObj, msObj->map->web.empty, BROWSE) != MS_SUCCESS)
-             return msWMSException(map, nVersion, NULL);
+           return msWMSException(map, nVersion, NULL, wms_exception_format);
      }
      else if (msReturnTemplateQuery(msObj, (char*)pszMimeType, NULL) != MS_SUCCESS)
-         return msWMSException(map, nVersion, NULL);
+       return msWMSException(map, nVersion, NULL, wms_exception_format);
 
      /* We don't want to free the map, and param names/values since they */
      /* belong to the caller, set them to NULL before freeing the mapservObj */
@@ -3004,9 +3006,9 @@
   {
      msSetError(MS_WMSERR, "Unsupported INFO_FORMAT value (%s).", "msWMSFeatureInfo()", info_format);
      if (nVersion >= OWS_1_3_0)
-       return msWMSException(map, nVersion, "InvalidFormat");
+       return msWMSException(map, nVersion, "InvalidFormat", wms_exception_format);
      else
-       return msWMSException(map, nVersion, NULL); 
+       return msWMSException(map, nVersion, NULL, wms_exception_format); 
   }
 
   return(MS_SUCCESS);
@@ -3016,7 +3018,7 @@
 ** msWMSDescribeLayer()
 */
 int msWMSDescribeLayer(mapObj *map, int nVersion, char **names,
-                       char **values, int numentries)
+                       char **values, int numentries, char *wms_exception_format)
 {
   int i = 0;
   char **layers = NULL;
@@ -3048,12 +3050,12 @@
   if (nVersion >= OWS_1_3_0 && sld_version == NULL)
   {
       msSetError(MS_WMSERR, "Missing required parameter SLD_VERSION", "DescribeLayer()");
-      return msWMSException(map, nVersion, "MissingParameterValue");
+      return msWMSException(map, nVersion, "MissingParameterValue", wms_exception_format);
   }
   if (nVersion >= OWS_1_3_0 && strcasecmp(sld_version, "1.1.0") != 0)
   {
       msSetError(MS_WMSERR, "SLD_VERSION must be 1.1.0", "DescribeLayer()");
-      return msWMSException(map, nVersion, "InvalidParameterValue");
+      return msWMSException(map, nVersion, "InvalidParameterValue", wms_exception_format);
   }
 
   if (encoding)
@@ -3219,7 +3221,7 @@
 ** msWMSGetLegendGraphic()
 */
 int msWMSGetLegendGraphic(mapObj *map, int nVersion, char **names,
-                       char **values, int numentries)
+                          char **values, int numentries, char *wms_exception_format)
 {
     char *pszLayer = NULL;
     char *pszFormat = NULL;
@@ -3281,23 +3283,23 @@
      if (!pszLayer)
      {
          msSetError(MS_WMSERR, "Mandatory LAYER parameter missing in GetLegendGraphic request.", "msWMSGetLegendGraphic()");
-         return msWMSException(map, nVersion, "LayerNotDefined");
+         return msWMSException(map, nVersion, "LayerNotDefined", wms_exception_format);
      }
      if (!pszFormat)
      {
          msSetError(MS_WMSERR, "Mandatory FORMAT parameter missing in GetLegendGraphic request.", "msWMSGetLegendGraphic()");
-         return msWMSException(map, nVersion, "InvalidFormat");
+         return msWMSException(map, nVersion, "InvalidFormat", wms_exception_format);
      }
 
      if (nVersion >= OWS_1_3_0 && sld_version == NULL)
      {
          msSetError(MS_WMSERR, "Missing required parameter SLD_VERSION", "GetLegendGraphic()");
-         return msWMSException(map, nVersion, "MissingParameterValue");
+         return msWMSException(map, nVersion, "MissingParameterValue", wms_exception_format);
      }
      if (nVersion >= OWS_1_3_0 && strcasecmp(sld_version, "1.1.0") != 0)
      {
          msSetError(MS_WMSERR, "SLD_VERSION must be 1.1.0", "GetLegendGraphic()");
-         return msWMSException(map, nVersion, "InvalidParameterValue");
+         return msWMSException(map, nVersion, "InvalidParameterValue", wms_exception_format);
      }
      /* check if layer name is valid. We only test the layer name and not */
      /* the group name. */
@@ -3315,7 +3317,7 @@
      {
          msSetError(MS_WMSERR, "Invalid layer given in the LAYER parameter.",
                  "msWMSGetLegendGraphic()");
-         return msWMSException(map, nVersion, "LayerNotDefined");
+         return msWMSException(map, nVersion, "LayerNotDefined", wms_exception_format);
      }
 
      /* validate format */
@@ -3340,7 +3342,7 @@
                         "Unsupported output format (%s).",
                         "msWMSGetLegendGraphic()",
                         values[i] );
-             return msWMSException(map, nVersion, "InvalidFormat");
+             return msWMSException(map, nVersion, "InvalidFormat", wms_exception_format);
          }
      }
      else
@@ -3358,7 +3360,7 @@
                         "Unsupported output format (%s).",
                         "msWMSGetLegendGraphic()",
                         pszFormat);
-             return msWMSException(map, nVersion, "InvalidFormat");
+             return msWMSException(map, nVersion, "InvalidFormat", wms_exception_format);
          }
      }
      msApplyOutputFormat(&(map->outputformat), psFormat, MS_NOOVERRIDE,
@@ -3379,7 +3381,7 @@
          {
              msSetError(MS_WMSERR, "style used in the STYLE parameter is not defined on the layer.", 
                         "msWMSGetLegendGraphic()");
-             return msWMSException(map, nVersion, "StyleNotDefined");
+             return msWMSException(map, nVersion, "StyleNotDefined", wms_exception_format);
          }
          else
          {
@@ -3473,16 +3475,16 @@
                         "Unavailable RULE (%s).",
                         "msWMSGetLegendGraphic()",
                         psRule);
-              return msWMSException(map, nVersion, "InvalidRule");
+             return msWMSException(map, nVersion, "InvalidRule", wms_exception_format);
          }
      }
 
      if (img == NULL)
-      return msWMSException(map, nVersion, NULL);
+       return msWMSException(map, nVersion, NULL, wms_exception_format);
 
      msIO_printf("Content-type: %s%c%c", MS_IMAGE_MIME_TYPE(map->outputformat), 10,10);
      if (msSaveImage(map, img, NULL) != MS_SUCCESS)
-       return msWMSException(map, nVersion, NULL);
+       return msWMSException(map, nVersion, NULL, wms_exception_format);
 
      msFreeImage(img);
 
@@ -3495,7 +3497,7 @@
 ** have a status set to on or default.
 */
 int msWMSGetStyles(mapObj *map, int nVersion, char **names,
-                       char **values, int numentries)
+                   char **values, int numentries, char *wms_exception_format)
 
 {
     int i,j,k;
@@ -3516,7 +3518,7 @@
             if (layers==NULL || numlayers < 1) {
                 msSetError(MS_WMSERR, "At least one layer name required in LAYERS.",
                    "msWMSGetStyles()");
-                return msWMSException(map, nVersion, NULL);
+                return msWMSException(map, nVersion, NULL, wms_exception_format);
             }
             for(j=0; j<map->numlayers; j++)
                GET_LAYER(map, j)->status = MS_OFF;
@@ -3544,7 +3546,7 @@
     {
         msSetError(MS_WMSERR, "Invalid layer(s) given in the LAYERS parameter.",
                    "msWMSGetStyles()");
-        return msWMSException(map, nVersion, "LayerNotDefined");
+        return msWMSException(map, nVersion, "LayerNotDefined", wms_exception_format);
     }
 
     if (nVersion <= OWS_1_1_1)
@@ -3620,6 +3622,7 @@
   int i, status, nVersion=OWS_VERSION_NOTSET;
   const char *version=NULL, *request=NULL, *service=NULL, *format=NULL, *updatesequence=NULL;
   const char * encoding;
+  char *wms_exception_format = NULL;
 
   encoding = msOWSLookupMetadata(&(map->web.metadata), "MO", "encoding");
 
@@ -3654,7 +3657,7 @@
        /* Invalid version format. msSetError() has been called by 
         * msOWSParseVersionString() and we return the error as an exception 
         */
-      return msWMSException(map, OWS_VERSION_NOTSET, NULL);
+    return msWMSException(map, OWS_VERSION_NOTSET, NULL, wms_exception_format);
   }
 
   /*
@@ -3667,7 +3670,7 @@
       (nVersion >= OWS_1_0_7 || nVersion == OWS_VERSION_NOTSET))
   {
       msSetError(MS_WMSERR, "Required SERVICE parameter missing.", "msWMSDispatch");
-      return msWMSException(map, nVersion, "ServiceNotDefined");
+      return msWMSException(map, nVersion, "ServiceNotDefined", wms_exception_format);
   }
 
   /*
@@ -3680,8 +3683,8 @@
       if (nVersion == OWS_VERSION_NOTSET)
           nVersion = OWS_1_3_0;/* VERSION is optional with getCapabilities only */
       if ((status = msOWSMakeAllLayersUnique(map)) != MS_SUCCESS)
-          return msWMSException(map, nVersion, NULL);
-      return msWMSGetCapabilities(map, nVersion, req, updatesequence);
+        return msWMSException(map, nVersion, NULL, wms_exception_format);
+      return msWMSGetCapabilities(map, nVersion, req, updatesequence, wms_exception_format);
   }
   else if (request && (strcasecmp(request, "context") == 0 ||
                        strcasecmp(request, "GetContext") == 0) )
@@ -3710,11 +3713,11 @@
       {
         msSetError(MS_WMSERR, "GetContext not enabled on this server.",
                    "msWMSDispatch()");
-        return msWMSException(map, nVersion, NULL);
+        return msWMSException(map, nVersion, NULL, wms_exception_format);
       }
 
       if ((status = msOWSMakeAllLayersUnique(map)) != MS_SUCCESS)
-          return msWMSException(map, nVersion, NULL);
+        return msWMSException(map, nVersion, NULL, wms_exception_format);
 
       if (encoding)
           msIO_printf("Content-type: text/xml; charset=%s%c%c", encoding,10,10);
@@ -3722,7 +3725,7 @@
           msIO_printf("Content-type: text/xml%c%c",10,10);
 
       if ( msWriteMapContext(map, stdout) != MS_SUCCESS )
-          return msWMSException(map, nVersion, NULL);
+        return msWMSException(map, nVersion, NULL, wms_exception_format);
       /* Request completed */
       return MS_SUCCESS;
   }
@@ -3765,7 +3768,7 @@
       msSetError(MS_WMSERR,
                  "Incomplete WMS request: VERSION parameter missing",
                  "msWMSDispatch()");
-      return msWMSException(map, OWS_VERSION_NOTSET, NULL);
+      return msWMSException(map, OWS_VERSION_NOTSET, NULL, wms_exception_format);
   }
 
   if (request==NULL)
@@ -3773,17 +3776,19 @@
       msSetError(MS_WMSERR,
                  "Incomplete WMS request: REQUEST parameter missing",
                  "msWMSDispatch()");
-      return msWMSException(map, nVersion, NULL);
+      return msWMSException(map, nVersion, NULL, wms_exception_format);
   }
 
   if ((status = msOWSMakeAllLayersUnique(map)) != MS_SUCCESS)
-      return msWMSException(map, nVersion, NULL);
+    return msWMSException(map, nVersion, NULL, wms_exception_format);
 
   if (strcasecmp(request, "GetLegendGraphic") == 0)
-    return msWMSGetLegendGraphic(map, nVersion, req->ParamNames, req->ParamValues, req->NumParams);
+    return msWMSGetLegendGraphic(map, nVersion, req->ParamNames, req->ParamValues, req->NumParams,
+                                 wms_exception_format);
 
   if (strcasecmp(request, "GetStyles") == 0)
-    return msWMSGetStyles(map, nVersion, req->ParamNames, req->ParamValues, req->NumParams);
+    return msWMSGetStyles(map, nVersion, req->ParamNames, req->ParamValues, req->NumParams, 
+                          wms_exception_format);
 
   else if (request && strcasecmp(request, "GetSchemaExtension") == 0)
     return msWMSGetSchemaExtension(map);
@@ -3792,25 +3797,29 @@
   if (strcasecmp(request, "map") == 0 || strcasecmp(request, "GetMap") == 0 ||
       strcasecmp(request, "feature_info") == 0 || strcasecmp(request, "GetFeatureInfo") == 0 || strcasecmp(request, "DescribeLayer") == 0)
   {
-      status = msWMSLoadGetMapParams(map, nVersion, req->ParamNames, req->ParamValues, req->NumParams);
+    status = msWMSLoadGetMapParams(map, nVersion, req->ParamNames, req->ParamValues, req->NumParams,
+                                   wms_exception_format);
       if (status != MS_SUCCESS) return status;
   }
 
 
   if (strcasecmp(request, "map") == 0 || strcasecmp(request, "GetMap") == 0)
-    return msWMSGetMap(map, nVersion, req->ParamNames, req->ParamValues, req->NumParams);
+    return msWMSGetMap(map, nVersion, req->ParamNames, req->ParamValues, req->NumParams, 
+                       wms_exception_format);
   else if (strcasecmp(request, "feature_info") == 0 || strcasecmp(request, "GetFeatureInfo") == 0)
-    return msWMSFeatureInfo(map, nVersion, req->ParamNames, req->ParamValues, req->NumParams);
+    return msWMSFeatureInfo(map, nVersion, req->ParamNames, req->ParamValues, req->NumParams,
+                            wms_exception_format);
   else if (strcasecmp(request, "DescribeLayer") == 0)
   {
-      return msWMSDescribeLayer(map, nVersion, req->ParamNames, req->ParamValues, req->NumParams);
+    return msWMSDescribeLayer(map, nVersion, req->ParamNames, req->ParamValues, req->NumParams,
+                              wms_exception_format);
   }
 
   /* Hummmm... incomplete or unsupported WMS request */
   if (service != NULL && strcasecmp(service, "WMS") == 0)
   {
       msSetError(MS_WMSERR, "Incomplete or unsupported WMS request", "msWMSDispatch()");
-      return msWMSException(map, nVersion, NULL);
+      return msWMSException(map, nVersion, NULL, wms_exception_format);
   }
   else
     return MS_DONE;  /* Not a WMS request */



More information about the mapserver-commits mailing list