Skip to content

Commit 95b4ebc

Browse files
committed
WMS server: detect correct service URL even if REQUEST_URI is not defined
1 parent 03edac9 commit 95b4ebc

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/server/qgswmsserver.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -2656,7 +2656,14 @@ bool QgsWMSServer::checkMaximumWidthHeight() const
26562656

26572657
QString QgsWMSServer::serviceUrl() const
26582658
{
2659-
QUrl mapUrl( getenv( "REQUEST_URI" ) );
2659+
QString requestUri = getenv( "REQUEST_URI" );
2660+
if ( requestUri.isEmpty() )
2661+
{
2662+
// in some cases (e.g. when running through python's CGIHTTPServer) the REQUEST_URI is not defined
2663+
requestUri = QString( getenv( "SCRIPT_NAME" ) ) + "?" + QString( getenv( "QUERY_STRING" ) );
2664+
}
2665+
2666+
QUrl mapUrl( requestUri );
26602667
mapUrl.setHost( getenv( "SERVER_NAME" ) );
26612668

26622669
//Add non-default ports to url

0 commit comments

Comments
 (0)