| 68 | */ |
| 69 | |
| 70 | int msWMSException(mapObj *map, int nVersion, const char *exception_code, |
| 71 | char *wms_exception_format) |
| 72 | { |
| 73 | const char *encoding; |
| 74 | char *schemalocation = NULL; |
| 75 | |
| 76 | /* Default to WMS 1.3.0 exceptions if version not set yet */ |
| 77 | if (nVersion <= 0) |
| 78 | nVersion = OWS_1_3_0; |
| 79 | |
| 80 | /* get scheam location */ |
| 81 | schemalocation = msEncodeHTMLEntities( msOWSGetSchemasLocation(map) ); |
| 82 | |
| 83 | encoding = msOWSLookupMetadata(&(map->web.metadata), "MO", "encoding"); |
| 84 | |
| 85 | /* Establish default exception format depending on VERSION */ |
| 86 | if (wms_exception_format == NULL) |
| 87 | { |
| 88 | if (nVersion <= OWS_1_0_0) |
| 89 | wms_exception_format = "INIMAGE"; /* WMS 1.0.0 */ |
| 90 | else if (nVersion <= OWS_1_0_7) |
| 91 | wms_exception_format = "SE_XML"; /* WMS 1.0.1 to 1.0.7 */ |
| 92 | else if (nVersion <= OWS_1_1_1) |
| 93 | wms_exception_format = "application/vnd.ogc.se_xml"; /* WMS 1.1.0 and later */ |
| 94 | else |
| 95 | wms_exception_format = "text/xml"; |
| 96 | } |
| 97 | |
| 98 | if (strcasecmp(wms_exception_format, "INIMAGE") == 0 || |
| 99 | strcasecmp(wms_exception_format, "BLANK") == 0 || |
| 100 | strcasecmp(wms_exception_format, "application/vnd.ogc.se_inimage")== 0 || |
| 101 | strcasecmp(wms_exception_format, "application/vnd.ogc.se_blank") == 0) |
| 102 | { |
| 103 | int blank = 0; |
| 104 | |
| 105 | if (strcasecmp(wms_exception_format, "BLANK") == 0 || |
| 106 | strcasecmp(wms_exception_format, "application/vnd.ogc.se_blank") == 0) |
| 107 | { |
| 108 | blank = 1; |
| 109 | } |
| 110 | |
| 111 | msWriteErrorImage(map, NULL, blank); |
| 112 | |
| 113 | } |
| 114 | else if (strcasecmp(wms_exception_format, "WMS_XML") == 0) /* Only in V1.0.0 */ |
| 115 | { |
| 116 | if (encoding) |
| 117 | msIO_printf("Content-type: text/xml; charset=%s%c%c", encoding,10,10); |
| 118 | else |
| 119 | msIO_printf("Content-type: text/xml%c%c",10,10); |
| 120 | |
| 121 | msIO_printf("<WMTException version=\"1.0.0\">\n"); |
| 122 | msWriteErrorXML(stdout); |
| 123 | msIO_printf("</WMTException>\n"); |
| 124 | } |
| 125 | else /* XML error, the default: SE_XML (1.0.1 to 1.0.7) */ |
| 126 | /* or application/vnd.ogc.se_xml (1.1.0 and later) */ |
| 127 | { |
no test coverage detected