[Mapbender-commits] r9712 - trunk/mapbender/owsproxy/http/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Mar 23 07:24:29 PDT 2017


Author: armin11
Date: 2017-03-23 07:24:29 -0700 (Thu, 23 Mar 2017)
New Revision: 9712

Modified:
   trunk/mapbender/owsproxy/http/classes/class_QueryHandler.php
Log:
Less exceptions

Modified: trunk/mapbender/owsproxy/http/classes/class_QueryHandler.php
===================================================================
--- trunk/mapbender/owsproxy/http/classes/class_QueryHandler.php	2017-03-23 14:23:18 UTC (rev 9711)
+++ trunk/mapbender/owsproxy/http/classes/class_QueryHandler.php	2017-03-23 14:24:29 UTC (rev 9712)
@@ -15,9 +15,10 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+require_once(dirname(__FILE__)."/../../../http/classes/class_owsPostQueryParser.php");
 
 /**
- * class to handle the querystring and the params
+ * simple class to handle the querystring and the params
  */
  
 class QueryHandler{
@@ -27,12 +28,36 @@
 	private $owsproxyServiceKey = 'wms';
 	private $owsproxyServiceId;
 	private $onlineResource;
+        private $hasPost = false;
 	/**
 	 * Constructor of the QueryHandler
 	 * 
 	 */
-	function __construct(){
+	function __construct($postData){
 		$this->setRequestParams(array_keys($_REQUEST));
+		if ($postData !== false) {
+			//parse post request for service / request / version parameters
+			//$e = new mb_exception("owsproxy/http/classes/class_QueryHandler.php: postData: ".$postData);
+			//try to parse it
+			$postQueryParser = new OwsPostQueryParser($postData);
+			//$e = new mb_exception($postQueryParser->serviceType);
+			//overwrite default parameters with those from post if found
+			if (isset($postQueryParser->serviceType) && $postQueryParser->serviceType !== '') {
+				$this->reqParams['service'] = $postQueryParser->serviceType;
+				$this->reqParamsToLower['service'] = $postQueryParser->serviceType;
+			}
+			if (isset($postQueryParser->serviceVersion) && $postQueryParser->serviceVersion !== '') {
+				$this->reqParams['version'] = $postQueryParser->serviceVersion;
+				$this->reqParamsToLower['version'] = $postQueryParser->serviceVersion;
+			}			
+			if (isset($postQueryParser->serviceRequestType) && $postQueryParser->serviceRequestType !== '') {
+				$this->reqParams['request'] = $postQueryParser->serviceRequestType;
+				$this->reqParamsToLower['request'] = $postQueryParser->serviceRequestType;
+
+			}
+			$this->hasPost = true;
+			
+		}
 		$notice = new mb_notice("const: querystring: ".$this->getQueryString());
 	}
 	
@@ -46,23 +71,22 @@
 	 * @return string[] an associative array with request parameters keys (tolowercase) and values (tolower)
 	 */
 	function setRequestParams($keys){
-       for($i=0; $i<count($keys); $i++){
-           //SZ, 30.11.2007, writing REQUEST parameter values into local variable
-           //as key will be modified
-           $reqValue = $_REQUEST[$keys[$i]];
-           if(strpos($keys[$i], "?") === 0){
-                           $keys[$i] = substr($keys[$i],1);
-           }
-           $this->reqParams[strtolower($keys[$i])] = $reqValue;
-           $this->reqParamsToLower[strtolower($keys[$i])] = $reqValue;
-           if($keys[$i] == $this->owsproxyServiceKey){
-               $this->owsproxyServiceId = $_REQUEST[$keys[$i]];
-               $notice = new mb_notice("owsId: ".$this->owsproxyServiceId);
-           }
-       }
-   }
+       		for($i=0; $i<count($keys); $i++){
+           		//SZ, 30.11.2007, writing REQUEST parameter values into local variable
+          	 	//as key will be modified
+          		$reqValue = $_REQUEST[$keys[$i]];
+          		if(strpos($keys[$i], "?") === 0){
+                       	    	$keys[$i] = substr($keys[$i],1);
+          	 	}
+          		$this->reqParams[strtolower($keys[$i])] = $reqValue;
+          	 	$this->reqParamsToLower[strtolower($keys[$i])] = $reqValue;
+          		if($keys[$i] == $this->owsproxyServiceKey){
+            	  	 	$this->owsproxyServiceId = $_REQUEST[$keys[$i]];
+            	  	 	$notice = new mb_notice("owsId: ".$this->owsproxyServiceId);
+           		}
+       		}
+   	}
 	
-	
 	/**
 	 * checks is a request param is part of the original request
 	 * 



More information about the Mapbender_commits mailing list