25 #include <fcgi_stdio.h> 35 QString uri = getenv(
"REQUEST_URI" );
39 uri = getenv(
"SCRIPT_NAME" );
45 if ( url.host().isEmpty() )
47 url.setHost( getenv(
"SERVER_NAME" ) );
51 if ( url.port( -1 ) == -1 )
53 QString portString = getenv(
"SERVER_PORT" );
54 if ( !portString.isEmpty() )
57 int portNumber = portString.toInt( &portOk );
58 if ( portOk && portNumber != 80 )
60 url.setPort( portNumber );
66 if ( url.scheme().isEmpty() )
68 QString( getenv(
"HTTPS" ) ).compare( QLatin1String(
"on" ), Qt::CaseInsensitive ) == 0
69 ? url.setScheme( QStringLiteral(
"https" ) )
70 : url.setScheme( QStringLiteral(
"http" ) );
79 const char *qs = getenv(
"QUERY_STRING" );
86 qDebug() <<
"fcgi query string: " << url.query();
92 const char *me = getenv(
"REQUEST_METHOD" );
96 if ( strcmp( me,
"POST" ) == 0 )
100 else if ( strcmp( me,
"PUT" ) == 0 )
104 else if ( strcmp( me,
"DELETE" ) == 0 )
108 else if ( strcmp( me,
"HEAD" ) == 0 )
137 void QgsFcgiServerRequest::readData()
140 const char *lengthstr = getenv(
"CONTENT_LENGTH" );
143 bool success =
false;
144 int length = QString( lengthstr ).toInt( &success );
149 const char *request_body = getenv(
"REQUEST_BODY" );
150 if ( success && request_body )
152 QString body( request_body );
153 body.truncate( length );
154 mData.append( body.toUtf8() );
158 qDebug() <<
"fcgi: reading " << lengthstr <<
" bytes from " << ( request_body ?
"REQUEST_BODY" :
"stdin" );
163 for (
int i = 0; i < length; ++i )
165 mData.append( getchar() );
181 void QgsFcgiServerRequest::printRequestInfos()
185 const QStringList envVars
187 QStringLiteral(
"SERVER_NAME" ),
188 QStringLiteral(
"REQUEST_URI" ),
189 QStringLiteral(
"REMOTE_ADDR" ),
190 QStringLiteral(
"REMOTE_HOST" ),
191 QStringLiteral(
"REMOTE_USER" ),
192 QStringLiteral(
"REMOTE_IDENT" ),
193 QStringLiteral(
"CONTENT_TYPE" ),
194 QStringLiteral(
"AUTH_TYPE" ),
195 QStringLiteral(
"HTTP_USER_AGENT" ),
196 QStringLiteral(
"HTTP_PROXY" ),
197 QStringLiteral(
"NO_PROXY" ),
198 QStringLiteral(
"HTTP_AUTHORIZATION" )
201 for (
const auto &envVar : envVars )
203 if ( getenv( envVar.toStdString().c_str() ) )
void setMethod(QgsServerRequest::Method method)
Set the request method.
void setUrl(const QUrl &url)
Set the request url.
Method
HTTP Method (or equivalent) used for the request.
MessageLevel
Level for messages This will be used both for message log and message bar in application.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
Qgis::MessageLevel logLevel() const
Gets the current log level.
QgsServerRequest::Method method() const
static QgsServerLogger * instance()
Gets the singleton instance.
QByteArray data() const override
Returns post/put data Check for QByteArray::isNull() to check if data is available.
void setOriginalUrl(const QUrl &url)
Set the request original url (the request url as seen by the web server)