summaryrefslogtreecommitdiff
path: root/inc/HTTPClient.php
diff options
context:
space:
mode:
authorAdrian Lang <dokuwiki@adrianlang.de>2010-12-08 17:17:40 +0100
committerAdrian Lang <dokuwiki@adrianlang.de>2010-12-08 17:43:28 +0100
commitfa7c70ff4d7f9999466436e7d559eb0c81571779 (patch)
tree3c4e2a1f55fe81f472e582cfea934004c7ad9287 /inc/HTTPClient.php
parent3733161e2de6b5a7092884f4e39ce8c846ae8f8c (diff)
downloadrpg-fa7c70ff4d7f9999466436e7d559eb0c81571779.tar.gz
rpg-fa7c70ff4d7f9999466436e7d559eb0c81571779.tar.bz2
tmp
Diffstat (limited to 'inc/HTTPClient.php')
-rw-r--r--inc/HTTPClient.php17
1 files changed, 9 insertions, 8 deletions
diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php
index 43b00034c..a9afef9f9 100644
--- a/inc/HTTPClient.php
+++ b/inc/HTTPClient.php
@@ -222,7 +222,7 @@ class HTTPClient {
$path = $uri['path'];
if(empty($path)) $path = '/';
if(!empty($uri['query'])) $path .= '?'.$uri['query'];
- $port = $uri['port'];
+ if(isset($uri['port']) && !empty($uri['port'])) $port = $uri['port'];
if(isset($uri['user'])) $this->user = $uri['user'];
if(isset($uri['pass'])) $this->pass = $uri['pass'];
@@ -235,7 +235,7 @@ class HTTPClient {
}else{
$request_url = $path;
$server = $server;
- if (empty($port)) $port = ($uri['scheme'] == 'https') ? 443 : 80;
+ if (!isset($port)) $port = ($uri['scheme'] == 'https') ? 443 : 80;
}
// add SSL stream prefix if needed - needs SSL support in PHP
@@ -506,12 +506,13 @@ class HTTPClient {
*/
function _parseHeaders($string){
$headers = array();
- $lines = explode("\n",$string);
- foreach($lines as $line){
- list($key,$val) = explode(':',$line,2);
- $key = strtolower(trim($key));
- $val = trim($val);
- if(empty($val)) continue;
+ if (!preg_match_all('/^\s*([\w-]+)\s*:\s*([\S \t]+)\s*$/m', $string,
+ $matches, PREG_SET_ORDER)) {
+ return $headers;
+ }
+ foreach($matches as $match){
+ list(, $key, $val) = $match;
+ $key = strtolower($key);
if(isset($headers[$key])){
if(is_array($headers[$key])){
$headers[$key][] = $val;