Changeset 1880
- Timestamp:
- 10/07/08 14:00:19 (1 month ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
framework/trunk/src/main/php/net/stubbles/peer/http/stubHTTPResponse.php
r1870 r1880 213 213 protected function readDefault($readLength) 214 214 { 215 return ($body = $this->socket->read($readLength)); 215 $body = $buffer = ''; 216 $read = 0; 217 218 while ($read < $readLength) { 219 $buffer = $this->socket->read($readLength); 220 $read += strlen($buffer); 221 $body .= $buffer; 222 } 223 224 return $body; 216 225 } 217 226 framework/trunk/src/main/php/net/stubbles/peer/stubSocket.php
r1763 r1880 74 74 return true; 75 75 } 76 76 77 77 if (null == $this->host) { 78 78 return false; 79 79 } 80 80 81 81 $errno = 0; 82 82 $errstr = ''; … … 86 86 throw new stubConnectionException('Connecting to ' . $this->host . ':' . $this->port . ' within ' . $this->timeout . ' seconds failed: ' . $errstr . ' (' . $errno . ').'); 87 87 } 88 88 89 89 socket_set_timeout($this->fp, $this->timeout); 90 90 return true; … … 107 107 * @param int $timeout timeout for connection in seconds 108 108 */ 109 function setTimeout($timeout)109 public function setTimeout($timeout) 110 110 { 111 111 $this->timeout = $timeout; … … 128 128 throw new stubIllegalStateException('Can not read on unconnected socket.'); 129 129 } 130 130 131 131 $data = fgets($this->fp, $length); 132 132 if (false === $data) { … … 161 161 throw new stubIllegalStateException('Can not read on unconnected socket.'); 162 162 } 163 163 164 164 $data = fread($this->fp, $length); 165 165 if (false === $data) { … … 183 183 throw new stubIllegalStateException('Can not write on unconnected socket.'); 184 184 } 185 185 186 186 $length = fputs($this->fp, $data, strlen($data)); 187 187 if (false === $length) { … … 237 237 * @return bool 238 238 */ 239 function eof()239 public function eof() 240 240 { 241 241 if ($this->isConnected() == true) { 242 242 return feof($this->fp); 243 243 } 244 244 245 245 return true; 246 246 } framework/trunk/src/test/php/net/stubbles/peer/http/stubHTTPResponseTestCase.php
r1870 r1880 310 310 $this->mockSocket->expects($this->once()) 311 311 ->method('read') 312 ->with($this->equalTo( 4096))312 ->with($this->equalTo(strlen('foobar'))) 313 313 ->will($this->returnValue('foobar')); 314 $this->assertEquals('foobar', $this->httpResponse->callReadDefault( 4096));314 $this->assertEquals('foobar', $this->httpResponse->callReadDefault(strlen('foobar'))); 315 315 } 316 316
