Changeset 2253

Show
Ignore:
Timestamp:
06/23/09 21:44:28 (13 months ago)
Author:
mikey
Message:

fixed defect #204: chunked encoding reading problems

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • framework/trunk/src/main/php/net/stubbles/peer/stubSocket.php

    r1880 r2253  
    7171    public function connect() 
    7272    { 
    73         if ($this->isConnected() == true) { 
     73        if ($this->isConnected() === true) { 
    7474            return true; 
    7575        } 
     
    9696    public function disconnect() 
    9797    { 
    98         if ($this->isConnected() == true) { 
     98        if ($this->isConnected() === true) { 
    9999            fclose($this->fp); 
    100100            $this->fp = null; 
     
    110110    { 
    111111        $this->timeout = $timeout; 
    112         if ($this->isConnected() == true) { 
     112        if ($this->isConnected() === true) { 
    113113            socket_set_timeout($this->fp, $this->timeout); 
    114114        } 
     
    125125    public function read($length = 4096) 
    126126    { 
    127         if ($this->isConnected() == false) { 
     127        if ($this->isConnected() === false) { 
    128128            throw new stubIllegalStateException('Can not read on unconnected socket.'); 
    129129        } 
     
    131131        $data = fgets($this->fp, $length); 
    132132        if (false === $data) { 
     133            // fgets returns false on eof while feof() returned false before 
     134            // but will now return true 
     135            if ($this->eof() === true) { 
     136                return null; 
     137            } 
     138             
    133139            throw new stubConnectionException('Reading of ' . $length . ' bytes failed.'); 
    134140        } 
     
    158164    public function readBinary($length = 1024) 
    159165    { 
    160         if ($this->isConnected() == false) { 
     166        if ($this->isConnected() === false) { 
    161167            throw new stubIllegalStateException('Can not read on unconnected socket.'); 
    162168        } 
     
    180186    public function write($data) 
    181187    { 
    182         if ($this->isConnected() == false) { 
     188        if ($this->isConnected() === false) { 
    183189            throw new stubIllegalStateException('Can not write on unconnected socket.'); 
    184190        } 
     
    239245    public function eof() 
    240246    { 
    241         if ($this->isConnected() == true) { 
     247        if ($this->isConnected() === true) { 
    242248            return feof($this->fp); 
    243249        }