Skip to content
Permalink
Browse files

Ensure url is complete in fcgi request

  • Loading branch information
dmarteau committed Jan 10, 2017
1 parent 2629690 commit 485ea82e3d203f0c3b48e16c0a7dc75f4212aecb
Showing with 37 additions and 3 deletions.
  1. +37 −3 src/server/qgsfcgiserverresponse.cpp
@@ -173,13 +173,47 @@ QgsFcgiServerRequest::QgsFcgiServerRequest()
{
mHasError = false;

// Rebuild the full URL

// Get the REQUEST_URI from the environment
QUrl url;
const char* uri = getenv( "REQUEST_URI" );
if ( uri )
QString uri = getenv( "REQUEST_URI" );
if ( uri.isEmpty() )
{
uri = getenv( "SCRIPT_NAME");
}

url.setUrl( uri );

// Check if host is defined
if( url.host().isEmpty() )
{
url.setHost( getenv( "SERVER_NAME" ) );
}

// Port ?
if( url.port(-1) == -1 )
{
url.setUrl( uri );
QString portString = getenv( "SERVER_PORT" );
if ( !portString.isEmpty() )
{
bool portOk;
int portNumber = portString.toInt( &portOk );
if ( portOk && portNumber != 80 )
{
url.setPort( portNumber );
}
}
}

// scheme
if( url.scheme().isEmpty() )
{
QString( getenv( "HTTPS" ) ).compare( QLatin1String( "on" ), Qt::CaseInsensitive ) == 0
? url.setScheme( QStringLiteral( "https" ) )
: url.setScheme( QStringLiteral( "http" ) );
}

// XXX OGC paremetrs are passed with the query string
// we override the query string url in case it is
// defined independently of REQUEST_URI

0 comments on commit 485ea82

Please sign in to comment.
You can’t perform that action at this time.