예제 #1
0
 public function testStopsCopyToSteamWhenReadFailsWithMaxLen()
 {
     $s1 = puzzle_stream_Stream::factory('foobaz');
     $s1 = puzzle_stream_FnStream::decorate($s1, array('read' => array($this, '__callback_returnEmpty')));
     $s2 = puzzle_stream_Stream::factory('');
     puzzle_stream_Utils::copyToStream($s1, $s2, 10);
     $this->assertEquals('', (string) $s2);
 }
예제 #2
0
 /**
  * @deprecated Moved to puzzle_stream_Utils::copyToStream
  */
 function puzzle_stream_copy_to_stream(puzzle_stream_StreamInterface $source, puzzle_stream_StreamInterface $dest, $maxLen = -1)
 {
     puzzle_stream_Utils::copyToStream($source, $dest, $maxLen);
 }
예제 #3
0
 /**
  * Drain the stream into the destination stream
  */
 private function getSaveToBody(puzzle_message_RequestInterface $request, puzzle_stream_StreamInterface $stream)
 {
     $config = $request->getConfig();
     if ($saveTo = $config['save_to']) {
         // Stream the response into the destination stream
         $saveTo = is_string($saveTo) ? new puzzle_stream_Stream(puzzle_stream_Utils::open($saveTo, 'r+')) : puzzle_stream_Stream::factory($saveTo);
     } else {
         // Stream into the default temp stream
         $saveTo = puzzle_stream_Stream::factory();
     }
     puzzle_stream_Utils::copyToStream($stream, $saveTo);
     $saveTo->seek(0);
     $stream->close();
     return $saveTo;
 }