[mapserver-commits] r9492 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Mon Oct 19 10:55:34 EDT 2009


Author: aboudreault
Date: 2009-10-19 10:55:32 -0400 (Mon, 19 Oct 2009)
New Revision: 9492

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapogcsos.c
   trunk/mapserver/mapwcs.c
   trunk/mapserver/mapwcs11.c
   trunk/mapserver/mapwfs.c
   trunk/mapserver/mapwfs11.c
   trunk/mapserver/mapwms.c
Log:
Added charset in content-type http header for wms/wfs/sos/wcs requests (#2583)

Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2009-10-18 14:22:44 UTC (rev 9491)
+++ trunk/mapserver/HISTORY.TXT	2009-10-19 14:55:32 UTC (rev 9492)
@@ -14,6 +14,8 @@
 Current Version (SVN trunk):
 ----------------------------
 
+- Added charset in content-type http header for wms/wfs/sos/wcs requests (#2583)
+
 Version 5.6.0-beta4 (2009-10-18):
 ---------------------------------
 

Modified: trunk/mapserver/mapogcsos.c
===================================================================
--- trunk/mapserver/mapogcsos.c	2009-10-18 14:22:44 UTC (rev 9491)
+++ trunk/mapserver/mapogcsos.c	2009-10-19 14:55:32 UTC (rev 9492)
@@ -79,6 +79,7 @@
   char *errorString     = NULL;
   char *errorMessage    = NULL;
   char *schemasLocation = NULL;
+  const char *encoding;
 
   xmlDocPtr  psDoc      = NULL;   
   xmlNodePtr psRootNode = NULL;
@@ -87,6 +88,7 @@
 
   psNsOws = xmlNewNs(NULL, BAD_CAST "http://www.opengis.net/ows/1.1", BAD_CAST "ows");
 
+  encoding = msOWSLookupMetadata(&(map->web.metadata), "SO", "encoding");
   errorString = msGetErrorString("\n");
   errorMessage = msEncodeHTMLEntities(errorString);
   schemasLocation = msEncodeHTMLEntities(msOWSGetSchemasLocation(map));
@@ -99,7 +101,11 @@
 
   psNsOws = xmlNewNs(psRootNode, BAD_CAST "http://www.opengis.net/ows/1.1", BAD_CAST "ows");
 
-  msIO_printf("Content-type: text/xml%c%c",10,10);
+  if (encoding)
+      msIO_printf("Content-type: text/xml; charset=%s%c%c", encoding,10,10);
+  else
+      msIO_printf("Content-type: text/xml%c%c",10,10);
+
   xmlDocDumpFormatMemoryEnc(psDoc, &buffer, &size, "ISO-8859-1", 1);
     
   msIO_printf("%s", buffer);
@@ -1172,6 +1178,7 @@
     char *xsi_schemaLocation = NULL;
     const char *script_url=NULL;
     const char *updatesequence=NULL;
+    const char *encoding;
 
     int i,j,k;
     layerObj *lp = NULL, *lpTmp = NULL;
@@ -1247,6 +1254,7 @@
 
     /* updateSequence */
     updatesequence = msOWSLookupMetadata(&(map->web.metadata), "SO", "updatesequence");
+    encoding = msOWSLookupMetadata(&(map->web.metadata), "SO", "encoding");
 
     if (sosparams->pszUpdateSequence != NULL) {
       i = msOWSNegotiateUpdateSequence(sosparams->pszUpdateSequence, updatesequence);
@@ -1693,7 +1701,10 @@
      if ( msIO_needBinaryStdout() == MS_FAILURE )
        return MS_FAILURE;
      
-     msIO_printf("Content-type: text/xml%c%c",10,10);
+     if (encoding)
+         msIO_printf("Content-type: text/xml; charset=%s%c%c", encoding,10,10);
+     else
+         msIO_printf("Content-type: text/xml%c%c",10,10);
     
     /*TODO* : check the encoding validity. Internally libxml2 uses UTF-8
     msOWSPrintEncodeMetadata(stdout, &(map->web.metadata),
@@ -1802,6 +1813,7 @@
   xmlNodePtr psObservationNode = NULL, psResultNode=NULL;
   const char *pszProcedure = NULL;
   const char *pszBlockSep=NULL;
+  const char *encoding;
   char *pszResult=NULL;
   int nDiffrentProc = 0;
   SOSProcedureNode *paDiffrentProc = NULL;
@@ -1813,6 +1825,8 @@
 
   /* establish local namespace */
   pszTmp = msOWSLookupMetadata(&(map->web.metadata), "SFO", "namespace_uri");
+  encoding = msOWSLookupMetadata(&(map->web.metadata), "SO", "encoding");
+
   if(pszTmp) user_namespace_uri = pszTmp;
 
   pszTmp = msOWSLookupMetadata(&(map->web.metadata), "SFO", "namespace_prefix");
@@ -2551,7 +2565,11 @@
     }
    
     /* output results */    
-     msIO_printf("Content-type: text/xml%c%c",10,10);
+    if (encoding)
+        msIO_printf("Content-type: text/xml; charset=%s%c%c", encoding,10,10);
+    else
+        msIO_printf("Content-type: text/xml%c%c",10,10);
+
      
      context = msIO_getHandler(stdout);
      xmlDocDumpFormatMemoryEnc(psDoc, &buffer, &size, "ISO-8859-1", 1);

Modified: trunk/mapserver/mapwcs.c
===================================================================
--- trunk/mapserver/mapwcs.c	2009-10-18 14:22:44 UTC (rev 9491)
+++ trunk/mapserver/mapwcs.c	2009-10-19 14:55:32 UTC (rev 9492)
@@ -127,6 +127,7 @@
                    const char *version )
 {
   char *pszEncodedVal = NULL;
+  const char *encoding;
 
   if( version == NULL )
       version = "1.0.0";
@@ -134,7 +135,12 @@
   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);
+  encoding = msOWSLookupMetadata(&(map->web.metadata), "CO", "encoding");
+  if (encoding)
+      msIO_printf("Content-type: application/vnd.ogc.se_xml; charset=%s%c%c", encoding,10,10);
+  else
+      msIO_printf("Content-type: application/vnd.ogc.se_xml%c%c",10,10);
+
   /* msIO_printf("Content-type: text/xml%c%c",10,10); */
 
   msOWSPrintEncodeMetadata(stdout, &(map->web.metadata), NULL, "wcs_encoding", OWS_NOERR, "<?xml version='1.0' encoding=\"%s\" ?>\n", "ISO-8859-1");
@@ -759,7 +765,10 @@
   int wcsSupportedVersions[] = {OWS_1_1_1, OWS_1_1_0, OWS_1_0_0};
   int wcsNumSupportedVersions = 3;
   const char *updatesequence=NULL;
+  const char *encoding;
 
+  encoding = msOWSLookupMetadata(&(map->web.metadata), "CO", "encoding");
+
 /* if version is not passed/set, set it to 1.1.1, this will trigger
     msOWSNegotiateVersion to handle accordingly
  
@@ -808,7 +817,10 @@
       strcasecmp(params->section, "/WCS_Capabilities/Capability") != 0 &&
       strcasecmp(params->section, "/WCS_Capabilities/ContentMetadata") != 0 &&
       strcasecmp(params->section, "/") != 0) {
-      msIO_printf("Content-type: application/vnd.ogc.se_xml%c%c",10,10);
+      if (encoding)
+          msIO_printf("Content-type: application/vnd.ogc.se_xml; charset=%s%c%c", encoding,10,10);
+      else
+          msIO_printf("Content-type: application/vnd.ogc.se_xml%c%c",10,10);
       msSetError( MS_WCSERR,
         "Invalid SECTION parameter \"%s\"",
         "msWCSGetCapabilities()", params->section);
@@ -817,7 +829,10 @@
   }
 
   else {
-    msIO_printf("Content-type: text/xml%c%c",10,10);
+      if (encoding)
+          msIO_printf("Content-type: text/xml; charset=%s%c%c", encoding,10,10);
+      else
+          msIO_printf("Content-type: text/xml%c%c",10,10);
   
     /* print common capability elements  */
     /* TODO: DocType? */
@@ -1138,9 +1153,11 @@
   const char *updatesequence=NULL;
   char **coverages=NULL;
   int numcoverages=0;
+  const char *encoding;
 
   char *coverageName=NULL; 
 
+  encoding = msOWSLookupMetadata(&(map->web.metadata), "CO", "encoding");
 /* -------------------------------------------------------------------- */
 /*      1.1.x is sufficiently different we have a whole case for        */
 /*      it.  The remainder of this function is for 1.0.0.               */
@@ -1176,7 +1193,10 @@
     updatesequence = strdup("0");
 
   /* printf("Content-type: application/vnd.ogc.se_xml%c%c",10,10); */
-  msIO_printf("Content-type: text/xml%c%c",10,10);
+  if (encoding)
+      msIO_printf("Content-type: text/xml; charset=%s%c%c", encoding,10,10);
+  else
+      msIO_printf("Content-type: text/xml%c%c",10,10);
 
   /* print common capability elements  */
   msOWSPrintEncodeMetadata(stdout, &(map->web.metadata), NULL, "wcs_encoding", OWS_NOERR, "<?xml version='1.0' encoding=\"%s\" ?>\n", "ISO-8859-1");

Modified: trunk/mapserver/mapwcs11.c
===================================================================
--- trunk/mapserver/mapwcs11.c	2009-10-18 14:22:44 UTC (rev 9491)
+++ trunk/mapserver/mapwcs11.c	2009-10-19 14:55:32 UTC (rev 9492)
@@ -59,6 +59,7 @@
   char *errorString     = NULL;
   char *errorMessage    = NULL;
   char *schemasLocation = NULL;
+  const char * encoding;
 
   xmlDocPtr  psDoc      = NULL;   
   xmlNodePtr psRootNode = NULL;
@@ -67,6 +68,7 @@
 
   psNsOws = xmlNewNs(NULL, BAD_CAST "http://www.opengis.net/ows/1.1", BAD_CAST "ows");
 
+  encoding = msOWSLookupMetadata(&(map->web.metadata), "CO", "encoding");
   errorString = msGetErrorString("\n");
   errorMessage = msEncodeHTMLEntities(errorString);
   schemasLocation = msEncodeHTMLEntities(msOWSGetSchemasLocation(map));
@@ -79,7 +81,11 @@
 
   psNsOws = xmlNewNs(psRootNode, BAD_CAST "http://www.opengis.net/ows/1.1", BAD_CAST "ows");
 
-  msIO_printf("Content-type: text/xml%c%c",10,10);
+  if (encoding)
+      msIO_printf("Content-type: text/xml; charset=%s%c%c", encoding,10,10);
+  else
+      msIO_printf("Content-type: text/xml%c%c",10,10);
+
   xmlDocDumpFormatMemoryEnc(psDoc, &buffer, &size, "ISO-8859-1", 1);
     
   msIO_printf("%s", buffer);
@@ -342,6 +348,7 @@
     xmlNodePtr psTmpNode;
     char *identifier_list = NULL, *format_list = NULL;
     const char *updatesequence=NULL;
+    const char *encoding;
     xmlNsPtr psOwsNs, psXLinkNs;
     char *schemaLocation = NULL;
     char *xsi_schemaLocation = NULL;
@@ -358,6 +365,7 @@
 /* -------------------------------------------------------------------- */
 
     updatesequence = msOWSLookupMetadata(&(map->web.metadata), "CO", "updatesequence");
+    encoding = msOWSLookupMetadata(&(map->web.metadata), "CO", "encoding");
 
     if (params->updatesequence != NULL) {
       i = msOWSNegotiateUpdateSequence(params->updatesequence, updatesequence);
@@ -554,7 +562,10 @@
     if( msIO_needBinaryStdout() == MS_FAILURE )
         return MS_FAILURE;
      
-    msIO_printf("Content-type: text/xml%c%c",10,10);
+    if (encoding)
+        msIO_printf("Content-type: text/xml; charset=%s%c%c", encoding,10,10);
+    else
+        msIO_printf("Content-type: text/xml%c%c",10,10);
     
     context = msIO_getHandler(stdout);
 
@@ -842,9 +853,12 @@
     xmlNsPtr psOwsNs, psXLinkNs;
     char *schemaLocation = NULL;
     char *xsi_schemaLocation = NULL;
+    const char *encoding;
 
     int i,j;
 
+    encoding = msOWSLookupMetadata(&(map->web.metadata), "CO", "encoding");
+
 /* -------------------------------------------------------------------- */
 /*      We will actually get the coverages list as a single item in     */
 /*      a string list with that item having the comma delimited         */
@@ -932,7 +946,10 @@
         if( msIO_needBinaryStdout() == MS_FAILURE )
             return MS_FAILURE;
      
-        msIO_printf("Content-type: text/xml%c%c",10,10);
+        if (encoding)
+            msIO_printf("Content-type: text/xml; charset=%s%c%c", encoding,10,10);
+        else
+            msIO_printf("Content-type: text/xml%c%c",10,10);
     
         context = msIO_getHandler(stdout);
 
@@ -1099,7 +1116,10 @@
 {
     int status, i;
     char *filename = NULL;
+    const char *encoding;
 
+    encoding = msOWSLookupMetadata(&(map->web.metadata), "CO", "encoding");
+
 /* -------------------------------------------------------------------- */
 /*      Fetch the driver we will be using and check if it supports      */
 /*      VSIL IO.                                                        */
@@ -1150,22 +1170,41 @@
 /* -------------------------------------------------------------------- */
 /*      Output stock header.                                            */
 /* -------------------------------------------------------------------- */
-    msIO_fprintf( 
-        stdout, 
-        "Content-Type: multipart/mixed; boundary=wcs%c%c"
-        "--wcs\n"
-        "Content-Type: text/xml\n"
-        "Content-ID: wcs.xml%c%c"
-        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
-        "<Coverages\n"
-        "     xmlns=\"http://www.opengis.net/wcs/1.1\"\n"
-        "     xmlns:ows=\"http://www.opengis.net/ows\"\n"
-        "     xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"
-        "     xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
-        "     xsi:schemaLocation=\"http://www.opengis.net/ows/1.1 ../owsCoverages.xsd\">\n"
-        "  <Coverage>\n",
-        10, 10,
-        10, 10 );
+    if (encoding)
+        msIO_fprintf( 
+            stdout, 
+            "Content-Type: multipart/mixed; boundary=wcs%c%c"
+            "--wcs\n"
+            "Content-Type: text/xml; charset=%s\n"
+            "Content-ID: wcs.xml%c%c"
+            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+            "<Coverages\n"
+            "     xmlns=\"http://www.opengis.net/wcs/1.1\"\n"
+            "     xmlns:ows=\"http://www.opengis.net/ows\"\n"
+            "     xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"
+            "     xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
+            "     xsi:schemaLocation=\"http://www.opengis.net/ows/1.1 ../owsCoverages.xsd\">\n"
+            "  <Coverage>\n",
+            10, 10,
+            encoding,
+            10, 10 );
+    else
+        msIO_fprintf( 
+            stdout, 
+            "Content-Type: multipart/mixed; boundary=wcs%c%c"
+            "--wcs\n"
+            "Content-Type: text/xml\n"
+            "Content-ID: wcs.xml%c%c"
+            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+            "<Coverages\n"
+            "     xmlns=\"http://www.opengis.net/wcs/1.1\"\n"
+            "     xmlns:ows=\"http://www.opengis.net/ows\"\n"
+            "     xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"
+            "     xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
+            "     xsi:schemaLocation=\"http://www.opengis.net/ows/1.1 ../owsCoverages.xsd\">\n"
+            "  <Coverage>\n",
+            10, 10,
+            10, 10 );
 
 /* -------------------------------------------------------------------- */
 /*      If we weren't able to write data under /vsimem, then we just    */

Modified: trunk/mapserver/mapwfs.c
===================================================================
--- trunk/mapserver/mapwfs.c	2009-10-18 14:22:44 UTC (rev 9491)
+++ trunk/mapserver/mapwfs.c	2009-10-19 14:55:32 UTC (rev 9492)
@@ -46,6 +46,7 @@
 int msWFSException(mapObj *map, const char *locator, const char *code,
                    const char *version )
 {
+    const char *encoding;
     char *schemalocation = NULL;
     /* In WFS, exceptions are always XML.
     */
@@ -56,7 +57,12 @@
     if( msOWSParseVersionString(version) >= OWS_1_1_0 )
       return msWFSException11( map, code, locator, version );
 
-    msIO_printf("Content-type: text/xml%c%c",10,10);
+    encoding = msOWSLookupMetadata(&(map->web.metadata), "FO", "encoding");
+    if (encoding)
+        msIO_printf("Content-type: text/xml; charset=%s%c%c", encoding,10,10);
+    else
+        msIO_printf("Content-type: text/xml%c%c",10,10);
+
     msOWSPrintEncodeMetadata(stdout, &(map->web.metadata), "FO", "encoding", OWS_NOERR,
                 "<?xml version='1.0' encoding=\"%s\" ?>\n", "ISO-8859-1");
 
@@ -304,13 +310,13 @@
   char *script_url=NULL, *script_url_encoded;
   const char *updatesequence=NULL;
   const char *wmtver=NULL;
+  const char *encoding;
   char tmpString[OWS_VERSION_MAXLEN];
   int wfsSupportedVersions[] = {OWS_1_1_0, OWS_1_0_0};
   int wfsNumSupportedVersions = 2;
 
   int i=0, tmpInt=0;
 
-  
   /* negotiate version */
   tmpInt = msOWSNegotiateVersion(msOWSParseVersionString(wfsparams->pszVersion), wfsSupportedVersions, 
                                  wfsNumSupportedVersions);
@@ -351,7 +357,12 @@
       }
   }
 
-  msIO_printf("Content-type: text/xml%c%c",10,10);
+  encoding = msOWSLookupMetadata(&(map->web.metadata), "FO", "encoding");
+    if (encoding)
+        msIO_printf("Content-type: text/xml; charset=%s%c%c", encoding,10,10);
+    else
+        msIO_printf("Content-type: text/xml%c%c",10,10);
+
   msOWSPrintEncodeMetadata(stdout, &(map->web.metadata), "FO", "encoding", OWS_NOERR,
                 "<?xml version='1.0' encoding=\"%s\" ?>\n",
                 "ISO-8859-1");
@@ -763,7 +774,11 @@
   /*
   ** DescribeFeatureType response
   */
-  msIO_printf("Content-type: text/xml%c%c",10,10);
+  value = msOWSLookupMetadata(&(map->web.metadata), "FO", "encoding");
+  if (value)
+      msIO_printf("Content-type: text/xml; charset=%s%c%c", value,10,10);
+  else
+      msIO_printf("Content-type: text/xml%c%c",10,10);
 
   msOWSPrintEncodeMetadata(stdout, &(map->web.metadata), "FO", "encoding", OWS_NOERR,
 			   "<?xml version='1.0' encoding=\"%s\" ?>\n",
@@ -1005,7 +1020,7 @@
   int iFIDLayers = 0;
   int iNumberOfFeatures = 0;
   int iResultTypeHits = 0;
-
+  
   gmlNamespaceListObj *namespaceList=NULL; /* for external application schema support */
 
   /* Default filter is map extents */
@@ -1586,7 +1601,11 @@
     */
     namespaceList = msGMLGetNamespaces(&(map->web), "G");
 
-    msIO_printf("Content-type: text/xml%c%c",10,10);
+    value = msOWSLookupMetadata(&(map->web.metadata), "FO", "encoding");
+    if (value)
+        msIO_printf("Content-type: text/xml; charset=%s%c%c", value,10,10);
+    else
+        msIO_printf("Content-type: text/xml%c%c",10,10);
 
     msOWSPrintEncodeMetadata(stdout, &(map->web.metadata), "FO", 
                              "encoding", OWS_NOERR,

Modified: trunk/mapserver/mapwfs11.c
===================================================================
--- trunk/mapserver/mapwfs11.c	2009-10-18 14:22:44 UTC (rev 9491)
+++ trunk/mapserver/mapwfs11.c	2009-10-19 14:55:32 UTC (rev 9492)
@@ -45,6 +45,7 @@
     char *errorString     = NULL;
     char *errorMessage    = NULL;
     char *schemasLocation = NULL;
+    const char *encoding;
 
     xmlDocPtr  psDoc      = NULL;   
     xmlNodePtr psRootNode = NULL;
@@ -56,6 +57,8 @@
 
     psNsOws = xmlNewNs(NULL, BAD_CAST "http://www.opengis.net/ows", BAD_CAST "ows");
 
+    encoding = msOWSLookupMetadata(&(map->web.metadata), "FO", "encoding");
+
     errorString = msGetErrorString("\n");
     errorMessage = msEncodeHTMLEntities(errorString);
     schemasLocation = msEncodeHTMLEntities(msOWSGetSchemasLocation(map));
@@ -68,7 +71,11 @@
 
     psNsOws = xmlNewNs(psRootNode, BAD_CAST "http://www.opengis.net/ows", BAD_CAST "ows");
 
-    msIO_printf("Content-type: text/xml%c%c",10,10);
+    if (encoding)
+        msIO_printf("Content-type: text/xml; charset=%s%c%c", encoding,10,10);
+    else
+        msIO_printf("Content-type: text/xml%c%c",10,10);
+
     xmlDocDumpFormatMemoryEnc(psDoc, &buffer, &size, "ISO-8859-1", 1);
     
     msIO_printf("%s", buffer);
@@ -208,6 +215,7 @@
 
     char *script_url=NULL, *script_url_encoded=NULL;
     const char *value = NULL;
+    const char *encoding;
 
     xmlChar *buffer = NULL;
     int size = 0, i;
@@ -221,6 +229,8 @@
 
     updatesequence = msOWSLookupMetadata(&(map->web.metadata), "FO", "updatesequence");
 
+    encoding = msOWSLookupMetadata(&(map->web.metadata), "FO", "encoding");
+
     if (params->pszUpdateSequence != NULL) {
       i = msOWSNegotiateUpdateSequence(params->pszUpdateSequence, updatesequence);
       if (i == 0) { /* current */
@@ -394,7 +404,10 @@
     if( msIO_needBinaryStdout() == MS_FAILURE )
         return MS_FAILURE;
      
-    msIO_printf("Content-type: text/xml%c%c",10,10);
+    if (encoding)
+        msIO_printf("Content-type: text/xml; charset=%s%c%c", encoding,10,10);
+    else
+        msIO_printf("Content-type: text/xml%c%c",10,10);
     
     context = msIO_getHandler(stdout);
 

Modified: trunk/mapserver/mapwms.c
===================================================================
--- trunk/mapserver/mapwms.c	2009-10-18 14:22:44 UTC (rev 9491)
+++ trunk/mapserver/mapwms.c	2009-10-19 14:55:32 UTC (rev 9492)
@@ -69,6 +69,7 @@
 
 int msWMSException(mapObj *map, int nVersion, const char *exception_code)
 {
+    const char *encoding;
     char *schemalocation = NULL;
 
     /* Default to WMS 1.1.1 exceptions if version not set yet */
@@ -78,6 +79,8 @@
     /* get scheam location */
     schemalocation = msEncodeHTMLEntities( msOWSGetSchemasLocation(map) );
 
+    encoding = msOWSLookupMetadata(&(map->web.metadata), "MO", "encoding");
+
   /* Establish default exception format depending on VERSION */
   if (wms_exception_format == NULL)
   {
@@ -109,7 +112,11 @@
   }
   else if (strcasecmp(wms_exception_format, "WMS_XML") == 0) /* Only in V1.0.0 */
   {
-    msIO_printf("Content-type: text/xml%c%c",10,10);
+      if (encoding)
+          msIO_printf("Content-type: text/xml; charset=%s%c%c", encoding,10,10);
+      else
+          msIO_printf("Content-type: text/xml%c%c",10,10);
+
     msIO_printf("<WMTException version=\"1.0.0\">\n");
     msWriteErrorXML(stdout);
     msIO_printf("</WMTException>\n");
@@ -120,7 +127,10 @@
     if (nVersion <= OWS_1_0_7)
     {
       /* In V1.0.1 to 1.0.7, the MIME type was text/xml */
-      msIO_printf("Content-type: text/xml%c%c",10,10);
+        if (encoding)
+            msIO_printf("Content-type: text/xml; charset=%s%c%c", encoding,10,10);
+        else
+            msIO_printf("Content-type: text/xml%c%c",10,10);
 
       msOWSPrintEncodeMetadata(stdout, &(map->web.metadata),
                                "MO", "encoding", OWS_NOERR,
@@ -134,8 +144,11 @@
     {
       /* In V1.1.0 and later, we have OGC-specific MIME types */
       /* we cannot return anything else than application/vnd.ogc.se_xml here. */
-      msIO_printf("Content-type: application/vnd.ogc.se_xml%c%c",10,10);
-
+        if (encoding)
+            msIO_printf("Content-type: application/vnd.ogc.se_xml; charset=%s%c%c", encoding,10,10);
+        else
+            msIO_printf("Content-type: application/vnd.ogc.se_xml%c%c",10,10);
+        
       msOWSPrintEncodeMetadata(stdout, &(map->web.metadata),
                                "MO", "encoding", OWS_NOERR,
                 "<?xml version='1.0' encoding=\"%s\" standalone=\"no\" ?>\n",
@@ -148,8 +161,12 @@
     }
     else if (nVersion <= OWS_1_1_1)/* 1.1.1 */
     {
-        msIO_printf("Content-type: application/vnd.ogc.se_xml%c%c",10,10);
+        if (encoding)
+            msIO_printf("Content-type: application/vnd.ogc.se_xml; charset=%s%c%c", encoding,10,10);
+        else
+            msIO_printf("Content-type: application/vnd.ogc.se_xml%c%c",10,10);
 
+
         msOWSPrintEncodeMetadata(stdout, &(map->web.metadata),
                                  "MO", "encoding", OWS_NOERR,
                   "<?xml version='1.0' encoding=\"%s\" standalone=\"no\" ?>\n",
@@ -160,9 +177,15 @@
     else /*1.3.0*/
     {
         if (strcasecmp(wms_exception_format, "application/vnd.ogc.se_xml") == 0)
-          msIO_printf("Content-type: application/vnd.ogc.se_xml%c%c",10,10);
+            if (encoding)
+                msIO_printf("Content-type: application/vnd.ogc.se_xml; charset=%s%c%c", encoding,10,10);
+            else
+                msIO_printf("Content-type: application/vnd.ogc.se_xml%c%c",10,10);
         else
-          msIO_printf("Content-type: text/xml%c%c",10,10);
+            if (encoding)
+                msIO_printf("Content-type: text/xml; charset=%s%c%c", encoding,10,10);
+            else
+                msIO_printf("Content-type: text/xml%c%c",10,10);
 
         msOWSPrintEncodeMetadata(stdout, &(map->web.metadata),
                                  "MO", "encoding", OWS_NOERR,
@@ -1919,6 +1942,7 @@
   char *schemalocation = NULL;
   const char *updatesequence=NULL;
   const char *sldenabled=NULL;
+  const char *encoding;
   char *pszTmp=NULL;
   int i;
 
@@ -1926,6 +1950,8 @@
 
   sldenabled = msOWSLookupMetadata(&(map->web.metadata), "MO", "sld_enabled");
 
+  encoding = msOWSLookupMetadata(&(map->web.metadata), "MO", "encoding");
+
   if (sldenabled == NULL)
       sldenabled = strdup("true");
 
@@ -1984,10 +2010,16 @@
       return msWMSException(map, nVersion, NULL);
   }
 
-  if (nVersion <= OWS_1_0_7 || nVersion >= OWS_1_3_0)
-      msIO_printf("Content-type: text/xml%c%c",10,10);  /* 1.0.0 to 1.0.7 and >=1.3.0*/
-  else
-      msIO_printf("Content-type: application/vnd.ogc.wms_xml%c%c",10,10);  /* 1.1.0 and later */
+  if (nVersion <= OWS_1_0_7 || nVersion >= OWS_1_3_0)   /* 1.0.0 to 1.0.7 and >=1.3.0*/
+      if (encoding)
+          msIO_printf("Content-type: text/xml; charset=%s%c%c", encoding,10,10);
+      else
+          msIO_printf("Content-type: text/xml%c%c",10,10);
+  else /* 1.1.0 and later */
+      if (encoding)
+          msIO_printf("Content-type: application/vnd.ogc.wms_xml; charset=%s%c%c", encoding,10,10);
+      else
+          msIO_printf("Content-type: application/vnd.ogc.wms_xml%c%c",10,10);
 
   msOWSPrintEncodeMetadata(stdout, &(map->web.metadata),
                            "MO", "encoding", OWS_NOERR,
@@ -2772,11 +2804,14 @@
   errorObj *ms_error = msGetErrorObj();
   int query_status=MS_NOERR;
   const char *pszMimeType=NULL;
+  const char *encoding;
   int query_layer = 0;
 
 
   pszMimeType = msOWSLookupMetadata(&(map->web.metadata), "MO", "FEATURE_INFO_MIME_TYPE");
 
+  encoding = msOWSLookupMetadata(&(map->web.metadata), "MO", "encoding");
+
   for(i=0; map && i<numentries; i++) {
     if(strcasecmp(names[i], "QUERY_LAYERS") == 0) {
       char **layers;
@@ -2902,7 +2937,10 @@
     /* MIME response... we're free to use any valid MIME type */
     int numresults = 0;
 
-    msIO_printf("Content-type: text/plain%c%c", 10,10);
+    if (encoding)
+        msIO_printf("Content-type: text/plain; charset=%s%c%c", encoding,10,10);
+    else
+        msIO_printf("Content-type: text/plain%c%c",10,10);
     msIO_printf("GetFeatureInfo results:\n");
 
     numresults = msDumpResult(map, 0, nVersion);
@@ -2913,9 +2951,15 @@
              strcasecmp(info_format, "application/vnd.ogc.gml") == 0) {
 
     if (nVersion <= OWS_1_0_7)
-        msIO_printf("Content-type: text/xml%c%c", 10,10);
+        if (encoding)
+            msIO_printf("Content-type: text/xml; charset=%s%c%c", encoding,10,10);
+        else
+            msIO_printf("Content-type: text/xml%c%c",10,10);
     else
-        msIO_printf("Content-type: application/vnd.ogc.gml%c%c", 10,10);
+        if (encoding)
+            msIO_printf("Content-type: application/vnd.ogc.gml; charset=%s%c%c", encoding,10,10);
+        else
+            msIO_printf("Content-type: application/vnd.ogc.gml%c%c",10,10);
 
     msGMLWriteQuery(map, NULL, "GMO"); /* default is stdout */
 
@@ -2983,7 +3027,10 @@
   char *schemalocation = NULL;
   char *version = NULL;
   char *sld_version = NULL;
+  const char *encoding;
 
+  encoding = msOWSLookupMetadata(&(map->web.metadata), "MO", "encoding");
+
   for(i=0; map && i<numentries; i++) {
       if(strcasecmp(names[i], "LAYERS") == 0) {
           layers = msStringSplit(values[i], ',', &numlayers);
@@ -3006,8 +3053,12 @@
       msSetError(MS_WMSERR, "SLD_VERSION must be 1.1.0", "DescribeLayer()");
       return msWMSException(map, nVersion, "InvalidParameterValue");
   }
-  msIO_printf("Content-type: text/xml\n\n");
-  
+
+  if (encoding)
+      msIO_printf("Content-type: text/xml; charset=%s%c%c", encoding,10,10);
+  else
+      msIO_printf("Content-type: text/xml%c%c",10,10);
+
   msOWSPrintEncodeMetadata(stdout, &(map->web.metadata),
                             "MO", "encoding", OWS_NOERR,
                             "<?xml version='1.0' encoding=\"%s\"?>\n",
@@ -3450,7 +3501,10 @@
     int numlayers = 0;
     char **layers = NULL;
     char  *sld = NULL;
+    const char *encoding;
 
+    encoding = msOWSLookupMetadata(&(map->web.metadata), "MO", "encoding");
+
     for(i=0; map && i<numentries; i++)
     {
         /* getMap parameters */
@@ -3493,14 +3547,20 @@
 
     if (nVersion <= OWS_1_1_1)
     {
-      msIO_printf("Content-type: application/vnd.ogc.sld+xml%c%c",10,10);
-      sld = msSLDGenerateSLD(map, -1, "1.0.0");
+        if (encoding)
+            msIO_printf("Content-type: application/vnd.ogc.sld+xml; charset=%s%c%c", encoding,10,10);
+        else
+            msIO_printf("Content-type: application/vnd.ogc.sld+xml%c%c",10,10);
+        sld = msSLDGenerateSLD(map, -1, "1.0.0");
     }
     else
     {   
       /*for wms 1.3.0 generate a 1.1 sld*/
-       msIO_printf("Content-type: text/xml%c%c",10,10);
-       sld = msSLDGenerateSLD(map, -1, "1.1.0");
+        if (encoding)
+            msIO_printf("Content-type: text/xml; charset=%s%c%c", encoding,10,10);
+        else
+            msIO_printf("Content-type: text/xml%c%c",10,10);
+        sld = msSLDGenerateSLD(map, -1, "1.1.0");
     }
     if (sld)
     {
@@ -3514,11 +3574,17 @@
 int msWMSGetSchemaExtension(mapObj *map) 
 {
     char *schemalocation = NULL;
+    const char *encoding;
 
     schemalocation = msEncodeHTMLEntities(msOWSGetSchemasLocation(map));
 
-    msIO_printf("Content-type: text/xml\n\n");
+    encoding = msOWSLookupMetadata(&(map->web.metadata), "MO", "encoding");
 
+    if (encoding)
+        msIO_printf("Content-type: text/xml; charset=%s%c%c", encoding,10,10);
+    else
+        msIO_printf("Content-type: text/xml%c%c",10,10);
+
     msOWSPrintEncodeMetadata(stdout, &(map->web.metadata),
                             "MO", "encoding", OWS_NOERR,
                             "<?xml version='1.0' encoding=\"%s\"?>\n",
@@ -3551,7 +3617,10 @@
 #ifdef USE_WMS_SVR
   int i, status, nVersion=OWS_VERSION_NOTSET;
   const char *version=NULL, *request=NULL, *service=NULL, *format=NULL, *updatesequence=NULL;
+  const char * encoding;
 
+  encoding = msOWSLookupMetadata(&(map->web.metadata), "MO", "encoding");
+
   /*
   ** Process Params common to all requests
   */
@@ -3644,7 +3713,12 @@
 
       if ((status = msOWSMakeAllLayersUnique(map)) != MS_SUCCESS)
           return msWMSException(map, nVersion, NULL);
-      msIO_printf("Content-type: text/xml\n\n");
+
+      if (encoding)
+          msIO_printf("Content-type: text/xml; charset=%s%c%c", encoding,10,10);
+      else
+          msIO_printf("Content-type: text/xml%c%c",10,10);
+
       if ( msWriteMapContext(map, stdout) != MS_SUCCESS )
           return msWMSException(map, nVersion, NULL);
       /* Request completed */
@@ -3654,7 +3728,10 @@
            format && strcasecmp(format,  "image/txt") == 0)
   {
       /* Until someone adds full support for ASCII graphics this should do. ;) */
-      msIO_printf("Content-type: text/plain\n\n");
+      if (encoding)
+          msIO_printf("Content-type: text/plain; charset=%s%c%c", encoding,10,10);
+      else
+          msIO_printf("Content-type: text/plain%c%c",10,10);
       msIO_printf(".\n               ,,ggddY\"\"\"Ybbgg,,\n          ,agd888b,_ "
              "\"Y8, ___'\"\"Ybga,\n       ,gdP\"\"88888888baa,.\"\"8b    \""
              "888g,\n     ,dP\"     ]888888888P'  \"Y     '888Yb,\n   ,dP\""



More information about the mapserver-commits mailing list