[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] phpgwapi/inc/class.net_http_client.inc.php, 1.4
From: |
nomail |
Subject: |
[Phpgroupware-cvs] phpgwapi/inc/class.net_http_client.inc.php, 1.4 |
Date: |
Thu, 30 Dec 2004 10:00:31 +0100 |
Update of /phpgwapi/inc
Modified Files:
Branch:
class.net_http_client.inc.php
date: 2004/12/30 09:00:31; author: skwashd; state: Exp; lines: +59 -18
Log Message:
vfs and dav fixes - patch #3525
=====================================================================
Index: phpgwapi/inc/class.net_http_client.inc.php
diff -u phpgwapi/inc/class.net_http_client.inc.php:1.3
phpgwapi/inc/class.net_http_client.inc.php:1.4
--- phpgwapi/inc/class.net_http_client.inc.php:1.3 Thu Dec 30 06:47:31 2004
+++ phpgwapi/inc/class.net_http_client.inc.php Thu Dec 30 09:00:31 2004
@@ -83,12 +83,12 @@
* Note : when host and port are defined, the connection is
immediate
* @see Connect()
**/
- function net_http_client( $host= NULL, $port= NULL )
+ function net_http_client( $host= NULL, $port= NULL, $ssl=False )
{
if( $this->debug & DBGTRACE ) echo "net_http_client(
$host, $port )\n";
if( $host != NULL ) {
- $this->connect( $host, $port );
+ $this->connect( $host, $port, $ssl );
}
}
@@ -217,17 +217,39 @@
* Connect
* open the connection to the server
* @param host string server address (or IP)
- * @param port string server listening port - defaults to 80
+ * @param port string server listening port - defaults to 80 ||
443
+ * @param ssl Boolean (True = ssl://, 2 = tls://, False = http)
* @return boolean false is connection failed, true otherwise
**/
- function Connect( $host, $port = NULL )
+ function Connect( $host, $port = NULL, $ssl=False )
{
if( $this->debug & DBGTRACE ) echo "Connect( $host,
$port ) \n";
- $this->url['scheme'] = "http";
$this->url['host'] = $host;
if( $port != NULL )
$this->url['port'] = $port;
+ if( $ssl )
+ {
+ switch ( $ssl )
+ {
+ case 2:
+ $this->url['scheme'] = 'tls';
+ break;
+ default:
+ $this->url['scheme'] = 'ssl';
+ break;
+ }
+ /* Unfortunately older version are not
supported */
+ if ( version_compare(phpversion(),"4.3.0") < 0 )
+ {
+ echo("<pre>Error :: You try to access
an ssl webdav repository while your php is not supporting it ! please upgrade
!</pre>" );
+ return False;
+ }
+ }
+ else
+ {
+ $this->url['scheme'] = 'http';
+ }
return true;
}
@@ -511,9 +533,10 @@
**/
function Unlock( $uri, $lockToken )
{
- $this->addHeader( "Lock-Token", "<$lockToken>" );
+ $this->addHeader( 'Lock-Token', "<$lockToken>" );
if( $this->sendCommand( "UNLOCK $uri
HTTP/$this->protocolVersion" ) )
$this->processReply();
+ $this->removeHeader('Lock-Token');
return $this->reply;
}
@@ -528,7 +551,7 @@
{
if( $this->debug & DBGTRACE ) echo "getHeaders()\n";
if( $this->debug & DBGINDATA ) {
- echo "DBG.INDATA responseHeaders="; print_r(
$this->responseHeaders );
+ echo 'DBG.INDATA responseHeaders='; print_r(
$this->responseHeaders );
}
return $this->responseHeaders;
}
@@ -606,8 +629,16 @@
$host = $this->proxyHost;
$port = $this->proxyPort;
} else {
- $host = $this->url['host'];
- $port = $this->url['port'];
+ if ( $this->url['scheme'] != 'http' )
+ {
+ $host = $this->url['scheme'] .
'://' . $this->url['host'];
+ $port =
empty($this->url['port']) ? '443' : $this->url['port'];
+ }
+ else
+ {
+ $host = $this->url['host'];
+ $port = $this->url['port'];
+ }
}
if( $port == "" ) $port = 80;
$this->socket = fsockopen( $host, $port,
&$this->reply, &$this->replyString );
@@ -687,7 +718,7 @@
$finished = false;
while ( ( ! $finished ) && ( ! feof($this->socket)) ) {
- $str = fgets( $this->socket, 1024 );
+ $str = @fgets( $this->socket, 1024 );
if( $this->debug & DBGINDATA ) echo "HEADER :
$str;";
$finished = ( $str == $lastLine );
if ( !$finished ) {
@@ -719,24 +750,34 @@
{
// chunked encoding
if( $this->debug & DBGSOCK ) echo "DBG.SOCK
chunked encoding..\n";
- $length = fgets($this->socket, 1024);
+ $length = @fgets($this->socket, 1024);
$length = hexdec($length);
while (true) {
if ($length == 0) { break; }
- $data .= fread($this->socket,
$length);
+ $data .= @fread($this->socket,
$length);
if( $this->debug & DBGSOCK )
echo "DBG.SOCK chunked encoding: read $length bytes\n";
- fgets($this->socket, 1024);
- $length = fgets($this->socket,
1024);
+ @fgets($this->socket, 1024);
+ $length = @fgets($this->socket,
1024);
$length = hexdec($length);
}
- fgets($this->socket, 1024);
+ @fgets($this->socket, 1024);
}
else if ($this->responseHeaders['Content-Length'] )
{
$length =
$this->responseHeaders['Content-Length'];
- $data = fread( $this->socket, $length );
+ /* this is for files bigger than 11Kb ?*/
+ do {
+ $buf = @fread ( $this->socket, 8192 );
+ /* Putting this here is better than
putting == 0 */
+ /* It's avoiding a fread on a 0 length
data which causes a warning when uses over ssl*/
+ $data .= $buf;
+ if ( strlen($buf) < 8192)
+ {
+ break;
+ }
+ } while ( True );
if( $this->debug & DBGSOCK ) echo "DBG.SOCK
socket_read using Content-Length ($length)\n";
}
@@ -756,11 +797,11 @@
break;
}
if( $status['unread_bytes'] > 0 ) {
- $buffer = fread( $this->socket,
$status['unread_bytes'] );
+ $buffer = @fread(
$this->socket, $status['unread_bytes'] );
$counter = 0;
} else {
$ts=time();
- $buffer = fread( $this->socket,
1024 );
+ $buffer = @fread(
$this->socket, 1024 );
sleep(0.1);
$failureCount++;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] phpgwapi/inc/class.net_http_client.inc.php, 1.4,
nomail <=