Skip to content
Permalink
Browse files

Merge pull request #4029 from dmarteau/cleanup_getenv

Move request logging to request object
  • Loading branch information
rldhont committed Jan 20, 2017
2 parents 85146ca + 8e025ae commit 5a2bd5dc8242d4354d75fbc70675a212cbd74d20
Showing with 63 additions and 57 deletions.
  1. +58 −0 src/server/qgsfcgiserverresponse.cpp
  2. +5 −0 src/server/qgsfcgiserverresponse.h
  3. +0 −53 src/server/qgsserver.cpp
  4. +0 −4 src/server/qgsserver.h
@@ -20,6 +20,7 @@
#include "qgis.h"
#include "qgsfcgiserverresponse.h"
#include "qgslogger.h"
#include "qgsserverlogger.h"
#include "qgsmessagelog.h"
#include <fcgi_stdio.h>

@@ -260,6 +261,13 @@ QgsFcgiServerRequest::QgsFcgiServerRequest()

setUrl( url );
setMethod( method );

// Output debug infos
QgsMessageLog::MessageLevel logLevel = QgsServerLogger::instance()->logLevel();
if ( logLevel <= QgsMessageLog::INFO )
{
printRequestInfos();
}
}

QgsFcgiServerRequest::~QgsFcgiServerRequest()
@@ -305,3 +313,53 @@ void QgsFcgiServerRequest::readData()
}
}

void QgsFcgiServerRequest::printRequestInfos()
{
QgsMessageLog::logMessage( QStringLiteral( "******************** New request ***************" ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
if ( getenv( "REMOTE_ADDR" ) )
{
QgsMessageLog::logMessage( "REMOTE_ADDR: " + QString( getenv( "REMOTE_ADDR" ) ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
if ( getenv( "REMOTE_HOST" ) )
{
QgsMessageLog::logMessage( "REMOTE_HOST: " + QString( getenv( "REMOTE_HOST" ) ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
if ( getenv( "REMOTE_USER" ) )
{
QgsMessageLog::logMessage( "REMOTE_USER: " + QString( getenv( "REMOTE_USER" ) ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
if ( getenv( "REMOTE_IDENT" ) )
{
QgsMessageLog::logMessage( "REMOTE_IDENT: " + QString( getenv( "REMOTE_IDENT" ) ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
if ( getenv( "CONTENT_TYPE" ) )
{
QgsMessageLog::logMessage( "CONTENT_TYPE: " + QString( getenv( "CONTENT_TYPE" ) ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
if ( getenv( "AUTH_TYPE" ) )
{
QgsMessageLog::logMessage( "AUTH_TYPE: " + QString( getenv( "AUTH_TYPE" ) ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
if ( getenv( "HTTP_USER_AGENT" ) )
{
QgsMessageLog::logMessage( "HTTP_USER_AGENT: " + QString( getenv( "HTTP_USER_AGENT" ) ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
if ( getenv( "HTTP_PROXY" ) )
{
QgsMessageLog::logMessage( "HTTP_PROXY: " + QString( getenv( "HTTP_PROXY" ) ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
if ( getenv( "HTTPS_PROXY" ) )
{
QgsMessageLog::logMessage( "HTTPS_PROXY: " + QString( getenv( "HTTPS_PROXY" ) ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
if ( getenv( "NO_PROXY" ) )
{
QgsMessageLog::logMessage( "NO_PROXY: " + QString( getenv( "NO_PROXY" ) ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
if ( getenv( "HTTP_AUTHORIZATION" ) )
{
QgsMessageLog::logMessage( "HTTP_AUTHORIZATION: " + QString( getenv( "HTTP_AUTHORIZATION" ) ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
}


@@ -92,6 +92,11 @@ class QgsFcgiServerRequest: public QgsServerRequest
private:
void readData();

// Log request info: print debug infos
// about the request
void printRequestInfos();


QByteArray mData;
bool mHasError;
};
@@ -148,58 +148,6 @@ void QgsServer::printRequestParameters( const QMap< QString, QString>& parameter
}
}

/**
* @brief QgsServer::printRequestInfos prints debug information about the request
*/
void QgsServer::printRequestInfos()
{
QgsMessageLog::logMessage( QStringLiteral( "******************** New request ***************" ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
if ( getenv( "REMOTE_ADDR" ) )
{
QgsMessageLog::logMessage( "REMOTE_ADDR: " + QString( getenv( "REMOTE_ADDR" ) ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
if ( getenv( "REMOTE_HOST" ) )
{
QgsMessageLog::logMessage( "REMOTE_HOST: " + QString( getenv( "REMOTE_HOST" ) ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
if ( getenv( "REMOTE_USER" ) )
{
QgsMessageLog::logMessage( "REMOTE_USER: " + QString( getenv( "REMOTE_USER" ) ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
if ( getenv( "REMOTE_IDENT" ) )
{
QgsMessageLog::logMessage( "REMOTE_IDENT: " + QString( getenv( "REMOTE_IDENT" ) ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
if ( getenv( "CONTENT_TYPE" ) )
{
QgsMessageLog::logMessage( "CONTENT_TYPE: " + QString( getenv( "CONTENT_TYPE" ) ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
if ( getenv( "AUTH_TYPE" ) )
{
QgsMessageLog::logMessage( "AUTH_TYPE: " + QString( getenv( "AUTH_TYPE" ) ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
if ( getenv( "HTTP_USER_AGENT" ) )
{
QgsMessageLog::logMessage( "HTTP_USER_AGENT: " + QString( getenv( "HTTP_USER_AGENT" ) ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
if ( getenv( "HTTP_PROXY" ) )
{
QgsMessageLog::logMessage( "HTTP_PROXY: " + QString( getenv( "HTTP_PROXY" ) ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
if ( getenv( "HTTPS_PROXY" ) )
{
QgsMessageLog::logMessage( "HTTPS_PROXY: " + QString( getenv( "HTTPS_PROXY" ) ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
if ( getenv( "NO_PROXY" ) )
{
QgsMessageLog::logMessage( "NO_PROXY: " + QString( getenv( "NO_PROXY" ) ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
if ( getenv( "HTTP_AUTHORIZATION" ) )
{
QgsMessageLog::logMessage( "HTTP_AUTHORIZATION: " + QString( getenv( "HTTP_AUTHORIZATION" ) ), QStringLiteral( "Server" ), QgsMessageLog::INFO );
}
}

/**
* @brief QgsServer::configPath
* @param defaultConfigPath
@@ -366,7 +314,6 @@ void QgsServer::handleRequest( QgsServerRequest& request, QgsServerResponse& res
if ( logLevel == QgsMessageLog::INFO )
{
time.start();
printRequestInfos();
}

//Pass the filters to the requestHandler, this is needed for the following reasons:
@@ -100,10 +100,6 @@ class SERVER_EXPORT QgsServer
// static methods of this class
static QString configPath( const QString& defaultConfigPath,
const QMap<QString, QString>& parameters );
// Mainly for debug
static void dummyMessageHandler( QtMsgType type, const char *msg );
// Mainly for debug
static void printRequestInfos();

/**
* @brief QgsServer::printRequestParameters prints the request parameters

0 comments on commit 5a2bd5d

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