当前位置: 首页>>代码示例>>PHP>>正文


PHP Client::setStream方法代码示例

本文整理汇总了PHP中Zend\Http\Client::setStream方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::setStream方法的具体用法?PHP Client::setStream怎么用?PHP Client::setStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Http\Client的用法示例。


在下文中一共展示了Client::setStream方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testStreamResponseNamed

    public function testStreamResponseNamed()
    {
        if (!($this->client->getAdapter() instanceof Adapter\StreamInterface)) {
              $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->send();

        $this->assertTrue($response instanceof 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!');
    }
开发者ID:benivaldo,项目名称:zf2-na-pratica,代码行数:25,代码来源:CommonHttpTests.php

示例2: downloadFromJotForm

 /**
  *
  * @param string $jotFormUrl        	
  * @throws UnableToRetrieveJotFormFile
  * @return $localFilePath
  */
 public function downloadFromJotForm($jotFormUrl, $password)
 {
     $client = new Client();
     $client->setUri($jotFormUrl);
     $client->setOptions(array('maxredirects' => 2, 'timeout' => 30));
     // Set Certification Path when https is used - does not work (yet)
     if (strpos($jotFormUrl, 'https:') === 0) {
         $client->setOptions(array('adapter' => 'Zend\\Http\\Client\\Adapter\\Curl', 'curloptions' => array(CURLOPT_FOLLOWLOCATION => TRUE, CURLOPT_SSL_VERIFYPEER => FALSE)));
     }
     // will use temp file
     $client->setStream();
     // Password, if set
     if (!empty($password)) {
         $client->setMethod(Request::METHOD_POST);
         $client->setParameterPost(array('passKey' => $password));
     }
     $response = $client->send();
     if ($response->getStatusCode() != 200) {
         throw new UnableToRetrieveJotFormFile('Wront StatusCode: ' . $response->getStatusCode() . ' (StatusCode=200 expected)');
     }
     // Copy StreamInput
     $tmpName = tempnam('/tmp', 'jotFormReport_');
     copy($response->getStreamName(), $tmpName);
     // Add to delete late
     $this->downloads[] = $tmpName;
     return $tmpName;
 }
开发者ID:stevenbuehner,项目名称:import-jot-form,代码行数:33,代码来源:JotFormDownloadHelper.php

示例3: prepareHttpRequest

 /**
  * Prepare req
  *
  * @param Request $request
  * @return Client
  * @author Paolo Agostinetto <paul.ago@gmail.com>
  */
 protected function prepareHttpRequest(Request $request)
 {
     $client = new Client("https://api.thumbalizr.com/", array('adapter' => 'Zend\\Http\\Client\\Adapter\\Curl', 'curloptions' => array(CURLOPT_FOLLOWLOCATION => TRUE, CURLOPT_SSL_VERIFYPEER => FALSE)));
     $client->setStream();
     // Use temp file
     $client->setParameterGet(array("api_key" => $this->apiKey, "quality" => $request->getQuality(), "width" => $request->getWidth(), "encoding" => $request->getEncoding(), "delay" => $request->getDelay(), "mode" => $request->getMode(), "bwidth" => $request->getBrowserWidth(), "bheight" => $request->getBrowserHeight(), "url" => $request->getUrl() . "&rnd=" . rand(100000, 999999999), "generate" => 0));
     return $client;
 }
开发者ID:agopaul,项目名称:thumbalizr,代码行数:15,代码来源:Thumbalizr.php


注:本文中的Zend\Http\Client::setStream方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。