Zend_Http_Client::setStream PHP Method

setStream() public method

Set streaming for received data
public setStream ( string | boolean $streamfile = true ) : Zend_Http_Client
$streamfile string | boolean Stream file, true for temp file, false/null for no streaming
return Zend_Http_Client
    public function setStream($streamfile = true)
    {
        $this->setConfig(array("output_stream" => $streamfile));
        return $this;
    }

Usage Example

Esempio n. 1
0
    public function testStreamResponseNamed()
    {
        if(!($this->client->getAdapter() instanceof Zend_Http_Client_Adapter_Stream)) {
              $this->markTestSkipped('Current adapter does not support streaming');
              return;
        }
        $this->client->setUri($this->baseuri . 'staticFile.jpg');
        $outfile = tempnam(sys_get_temp_dir(), "outstream");
        $this->client->setStream($outfile);

        $response = $this->client->request();

        $this->assertTrue($response instanceof Zend_Http_Response_Stream, 'Request did not return stream response!');
        $this->assertTrue(is_resource($response->getStream()), 'Request does not contain stream!');

        $this->assertEquals($outfile, $response->getStreamName());

        $stream_read = stream_get_contents($response->getStream());
        $file_read = file_get_contents($outfile);

        $expected = $this->_getTestFileContents('staticFile.jpg');

        $this->assertEquals($expected, $stream_read, 'Downloaded stream does not seem to match!');
        $this->assertEquals($expected, $file_read, 'Downloaded file does not seem to match!');
    }
All Usage Examples Of Zend_Http_Client::setStream