** msWMSDispatch() is the entry point for WMS requests. ** - If this is a valid request then it is processed and MS_SUCCESS is returned ** on success, or MS_FAILURE on failure. ** - If this does not appear to be a valid WMS request then MS_DONE ** is returned and MapServer is expected to process this as a regular ** MapServer request. */
| 3897 | ** MapServer request. |
| 3898 | */ |
| 3899 | int msWMSDispatch(mapObj *map, cgiRequestObj *req, owsRequestObj *ows_request, int force_wms_mode) |
| 3900 | { |
| 3901 | #ifdef USE_WMS_SVR |
| 3902 | int i, status, nVersion=OWS_VERSION_NOTSET; |
| 3903 | const char *version=NULL, *request=NULL, *service=NULL, *format=NULL, *updatesequence=NULL; |
| 3904 | const char * encoding; |
| 3905 | char *wms_exception_format = NULL; |
| 3906 | |
| 3907 | encoding = msOWSLookupMetadata(&(map->web.metadata), "MO", "encoding"); |
| 3908 | |
| 3909 | /* |
| 3910 | ** Process Params common to all requests |
| 3911 | */ |
| 3912 | /* VERSION (WMTVER in 1.0.0) and REQUEST must be present in a valid request */ |
| 3913 | for(i=0; i<req->NumParams; i++) { |
| 3914 | if(strcasecmp(req->ParamNames[i], "VERSION") == 0) |
| 3915 | version = req->ParamValues[i]; |
| 3916 | else if (strcasecmp(req->ParamNames[i], "WMTVER") == 0 && version == NULL) |
| 3917 | version = req->ParamValues[i]; |
| 3918 | else if (strcasecmp(req->ParamNames[i], "UPDATESEQUENCE") == 0) |
| 3919 | updatesequence = req->ParamValues[i]; |
| 3920 | else if (strcasecmp(req->ParamNames[i], "REQUEST") == 0) |
| 3921 | request = req->ParamValues[i]; |
| 3922 | else if (strcasecmp(req->ParamNames[i], "EXCEPTIONS") == 0) |
| 3923 | wms_exception_format = req->ParamValues[i]; |
| 3924 | else if (strcasecmp(req->ParamNames[i], "SERVICE") == 0) |
| 3925 | service = req->ParamValues[i]; |
| 3926 | else if (strcasecmp(req->ParamNames[i], "FORMAT") == 0) |
| 3927 | format = req->ParamValues[i]; |
| 3928 | } |
| 3929 | |
| 3930 | /* If SERVICE is specified then it MUST be "WMS" */ |
| 3931 | if (service != NULL && strcasecmp(service, "WMS") != 0) |
| 3932 | return MS_DONE; /* Not a WMS request */ |
| 3933 | |
| 3934 | nVersion = msOWSParseVersionString(version); |
| 3935 | if (nVersion == OWS_VERSION_BADFORMAT) |
| 3936 | { |
| 3937 | /* Invalid version format. msSetError() has been called by |
| 3938 | * msOWSParseVersionString() and we return the error as an exception |
| 3939 | */ |
| 3940 | return msWMSException(map, OWS_VERSION_NOTSET, NULL, wms_exception_format); |
| 3941 | } |
| 3942 | |
| 3943 | /* |
| 3944 | ** GetCapbilities request needs the service parametr defined as WMS: |
| 3945 | see section 7.1.3.2 wms 1.1.1 specs for decsription. |
| 3946 | */ |
| 3947 | if (request && service == NULL && |
| 3948 | (strcasecmp(request, "capabilities") == 0 || |
| 3949 | strcasecmp(request, "GetCapabilities") == 0) && |
| 3950 | (nVersion >= OWS_1_0_7 || nVersion == OWS_VERSION_NOTSET)) |
| 3951 | { |
| 3952 | if (force_wms_mode) |
| 3953 | { |
| 3954 | msSetError(MS_WMSERR, "Required SERVICE parameter missing.", "msWMSDispatch"); |
| 3955 | return msWMSException(map, nVersion, "ServiceNotDefined", wms_exception_format); |
| 3956 | } |
no test coverage detected