@@ -71,7 +71,7 @@ QgsFcgiServerRequest::QgsFcgiServerRequest()
7171 }
7272
7373 // Store the URL before the server rewrite that could have been set in QUERY_STRING
74- mOriginalUrl = url;
74+ setOriginalUrl ( url ) ;
7575
7676 // OGC parameters are passed with the query string, which is normally part of
7777 // the REQUEST_URI, we override the query string url in case it is defined
@@ -133,26 +133,33 @@ QByteArray QgsFcgiServerRequest::data() const
133133 return mData ;
134134}
135135
136- QUrl QgsFcgiServerRequest::url () const
137- {
138- return mOriginalUrl .isEmpty () ? QgsServerRequest::url () : mOriginalUrl ;
139- }
140-
141136// Read post put data
142137void QgsFcgiServerRequest::readData ()
143138{
144139 // Check if we have CONTENT_LENGTH defined
145140 const char *lengthstr = getenv ( " CONTENT_LENGTH" );
146141 if ( lengthstr )
147142 {
148- #ifdef QGISDEBUG
149- qDebug () << " fcgi: reading " << lengthstr << " bytes from stdin" ;
150- #endif
151143 bool success = false ;
152144 int length = QString ( lengthstr ).toInt ( &success );
145+ // Note: REQUEST_BODY is not part of CGI standard, and it is not
146+ // normally passed by any CGI web server and it is implemented only
147+ // to allow unit tests to inject a request body and simulate a POST
148+ // request
149+ const char *request_body = getenv ( " REQUEST_BODY" );
150+ if ( success && request_body )
151+ {
152+ QString body ( request_body );
153+ body.truncate ( length );
154+ mData .append ( body.toUtf8 () );
155+ length = 0 ;
156+ }
157+ #ifdef QGISDEBUG
158+ qDebug () << " fcgi: reading " << lengthstr << " bytes from " << ( request_body ? " REQUEST_BODY" : " stdin" );
159+ #endif
153160 if ( success )
154161 {
155- // XXX This not efficiont at all !!
162+ // XXX This not efficient at all !!
156163 for ( int i = 0 ; i < length; ++i )
157164 {
158165 mData .append ( getchar () );
0 commit comments