[Mapbender-commits] r2074 - branches/2.5/http/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Feb 8 07:56:06 EST 2008


Author: verenadiewald
Date: 2008-02-08 07:56:06 -0500 (Fri, 08 Feb 2008)
New Revision: 2074

Modified:
   branches/2.5/http/classes/class_connector.php
Log:
check if it is a xml string in function getHTTP()

Modified: branches/2.5/http/classes/class_connector.php
===================================================================
--- branches/2.5/http/classes/class_connector.php	2008-02-08 12:55:06 UTC (rev 2073)
+++ branches/2.5/http/classes/class_connector.php	2008-02-08 12:56:06 UTC (rev 2074)
@@ -92,7 +92,7 @@
 					$e = new mb_exception("class_connector.php: invalid http type '" . $value . "'");
 				}
 				break;
-			
+							
 			case "httpType":
 				if (in_array(mb_strtoupper($value), array("POST", "GET"))) {
 					$this->httpType = $value;
@@ -159,8 +159,8 @@
 
 	private function getHTTP($url){
 		if ($this->httpType == "get") {
-			return @file_get_contents($url);	
-		}
+			return @file_get_contents($url);
+	 	}
 		else {
 			$urlComponentArray = parse_url($url);
 			$host = $urlComponentArray["host"];
@@ -169,7 +169,6 @@
 				$port = 80;		
 			}	
 			$path = $urlComponentArray["path"];
-			
 			$buf = '';
 		    $fp = fsockopen($host, $port);
 		    fputs($fp, "POST $path HTTP/".$this->httpVersion . "\r\n");
@@ -180,9 +179,16 @@
 		    fputs($fp, "Content-length: " . strlen($this->httpPostData) . "\r\n");
 		    fputs($fp, "Connection: close\r\n\r\n");
 		    fputs($fp, $this->httpPostData);
+		    $xmlstr = false;
 		    while (!feof($fp)) {
-		    	$buf .= fgets($fp,4096);	
-		    }
+		    	$content = fgets($fp,4096);
+		    	if( strpos($content, '<?xml') === 0){
+		    		$xmlstr = true;
+		    	}
+		    	if($xmlstr == true){
+		    		$buf .= $content;
+		    	}
+			}
 		    fclose($fp);
 		    return $buf;			
 		}



More information about the Mapbender_commits mailing list