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


PHP Response::sendContent方法代码示例

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


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

示例1: sendContent

 /**
  * Sends the file.
  */
 public function sendContent()
 {
     if (!$this->isSuccessful()) {
         parent::sendContent();
         return;
     }
     $outStream = fopen('php://output', 'wb');
     $fileStream = $this->file->readStream();
     stream_copy_to_stream($fileStream, $outStream);
     fclose($outStream);
     fclose($fileStream);
 }
开发者ID:Fedott,项目名称:secure-file-storage,代码行数:15,代码来源:StreamFileResponse.php

示例2: sendContent

 /**
  * Sends content for the current web response.
  *
  * @param ReactResponse   $response
  * @param SymfonyResponse $sf_response
  */
 private function sendContent(ReactResponse $response, SymfonyResponse $sf_response)
 {
     if ($sf_response instanceof StreamedResponse || $sf_response instanceof BinaryFileResponse) {
         ob_start(function ($buffer) use($response) {
             $response->write($buffer);
         });
         $sf_response->sendContent();
         ob_get_clean();
         $response->end();
     } else {
         $response->end($sf_response->getContent());
     }
 }
开发者ID:KEIII,项目名称:react-silex,代码行数:19,代码来源:ResponseBridge.php

示例3: sendContent

 /**
  * Sends the file.
  */
 public function sendContent()
 {
     if (!$this->isSuccessful()) {
         parent::sendContent();
         return;
     }
     if (0 === $this->maxlen) {
         return;
     }
     $out = fopen('php://output', 'wb');
     $file = fopen($this->file->getPathname(), 'rb');
     stream_copy_to_stream($file, $out, $this->maxlen, $this->offset);
     fclose($out);
     fclose($file);
 }
开发者ID:Gordondalos,项目名称:erp,代码行数:18,代码来源:BinaryFileResponse.php

示例4: testSendContent

 public function testSendContent()
 {
     $response = new Response('test response rendering', 200);
     ob_start();
     $response->sendContent();
     $string = ob_get_clean();
     $this->assertContains('test response rendering', $string);
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:8,代码来源:ResponseTest.php

示例5: deliver

 /**
  * Delivers the Response as a string.
  *
  * When the Response is a StreamedResponse, the content is streamed immediately
  * instead of being returned.
  *
  * @param Response $response A Response instance
  *
  * @return string|null The Response content or null when the Response is streamed
  *
  * @throws \RuntimeException when the Response is not successful
  */
 protected function deliver(Response $response)
 {
     if (!$response->isSuccessful()) {
         throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %s).', $this->requests[0]->getUri(), $response->getStatusCode()));
     }
     if (!$response instanceof StreamedResponse) {
         return $response->getContent();
     }
     $response->sendContent();
 }
开发者ID:ronaldlunaramos,项目名称:webstore,代码行数:22,代码来源:FragmentHandler.php

示例6: filterResponse

 /**
  * Converts the HttpKernel response to a BrowserKit response.
  *
  * @param Response $response A Response instance
  *
  * @return DomResponse A DomResponse instance
  */
 protected function filterResponse($response)
 {
     $headers = $response->headers->all();
     if ($response->headers->getCookies()) {
         $cookies = array();
         foreach ($response->headers->getCookies() as $cookie) {
             $cookies[] = new DomCookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
         }
         $headers['Set-Cookie'] = $cookies;
     }
     // this is needed to support StreamedResponse
     ob_start();
     $response->sendContent();
     $content = ob_get_clean();
     return new DomResponse($content, $response->getStatusCode(), $headers);
 }
开发者ID:omusico,项目名称:lafayettehelps.com,代码行数:23,代码来源:Client.php

示例7: createResponse

 /**
  * {@inheritdoc}
  */
 public function createResponse(Response $symfonyResponse)
 {
     if ($symfonyResponse instanceof BinaryFileResponse) {
         $stream = new DiactorosStream($symfonyResponse->getFile()->getPathname(), 'r');
     } else {
         $stream = new DiactorosStream('php://temp', 'wb+');
         if ($symfonyResponse instanceof StreamedResponse) {
             ob_start(function ($buffer) use($stream) {
                 $stream->write($buffer);
                 return false;
             });
             $symfonyResponse->sendContent();
             ob_end_clean();
         } else {
             $stream->write($symfonyResponse->getContent());
         }
     }
     $headers = $symfonyResponse->headers->all();
     $cookies = $symfonyResponse->headers->getCookies();
     if (!empty($cookies)) {
         $headers['Set-Cookie'] = array();
         foreach ($cookies as $cookie) {
             $headers['Set-Cookie'][] = $cookie->__toString();
         }
     }
     $response = new DiactorosResponse($stream, $symfonyResponse->getStatusCode(), $headers);
     $protocolVersion = $symfonyResponse->getProtocolVersion();
     if ('1.1' !== $protocolVersion) {
         $response = $response->withProtocolVersion($protocolVersion);
     }
     return $response;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:35,代码来源:DiactorosFactory.php

示例8: sendContent

 /**
  * Sends the file.
  */
 public function sendContent()
 {
     if (!$this->isSuccessful()) {
         parent::sendContent();
         return;
     }
     if (0 === $this->maxlen) {
         return;
     }
     $out = fopen('php://output', 'wb');
     $in = $this->ioService->getFileInputStream($this->file);
     stream_copy_to_stream($in, $out, $this->maxlen, $this->offset);
     fclose($out);
 }
开发者ID:ezsystems,项目名称:ezpublish-kernel,代码行数:17,代码来源:BinaryStreamResponse.php

示例9: filterResponse

    /**
     * Converts the HttpKernel response to a BrowserKit response.
     *
     * @param Response $response A Response instance
     *
     * @return DomResponse A DomResponse instance
     */
    protected function filterResponse($response)
    {
        // this is needed to support StreamedResponse
        ob_start();
        $response->sendContent();
        $content = ob_get_clean();

        return new DomResponse($content, $response->getStatusCode(), $response->headers->all());
    }
开发者ID:symfony,项目名称:symfony,代码行数:16,代码来源:Client.php

示例10: sendContent

 /**
  * Allow Tlog to write log stuff in the fina content.
  *
  * @see \Thelia\Core\HttpFoundation\Response::sendContent()
  */
 public function sendContent()
 {
     Tlog::getInstance()->write($this->content);
     parent::sendContent();
 }
开发者ID:margery,项目名称:thelia,代码行数:10,代码来源:Response.php

示例11: mapResponse

 /**
  * Convert Symfony\Component\HttpFoundation\Response to React\Http\Response
  *
  * @param ReactResponse $reactResponse
  * @param SymfonyResponse $syResponse
  */
 protected static function mapResponse(ReactResponse $reactResponse, SymfonyResponse $syResponse)
 {
     $headers = $syResponse->headers->all();
     $reactResponse->writeHead($syResponse->getStatusCode(), $headers);
     // @TODO convert StreamedResponse in an async manner
     if ($syResponse instanceof SymfonyStreamedResponse) {
         ob_start();
         $syResponse->sendContent();
         $content = ob_get_contents();
         ob_end_clean();
     } else {
         $content = $syResponse->getContent();
     }
     $reactResponse->end($content);
 }
开发者ID:nghenglim,项目名称:php-pm-httpkernel,代码行数:21,代码来源:HttpKernel.php

示例12: download

 /**
  * 
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function download()
 {
     $response = new Response($this->_data, 200, array('Content-Type' => 'text/plain', 'Content-Disposition' => 'attachment; filename="' . $this->getFilename() . '"'));
     $response->sendHeaders();
     $response->sendContent();
     $this->_incrementFileIndex();
     return $response;
 }
开发者ID:defan-marunchak,项目名称:eurotax,代码行数:12,代码来源:TransDeb.php

示例13: handleBackupAction

 /**
  * Handle and execute backup of connection
  *
  * @Route("/backup/{key}", name="handleBackup")
  *
  * @param int     $key          key of connected device
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function handleBackupAction($key)
 {
     $dataClass = $this->get('DataModel');
     $params = array('key' => $key, 'filter' => '');
     $res = $dataClass->handle('backup', $params, false);
     $resp = new Response();
     $resp->setStatusCode(200);
     $resp->headers->set('Cache-Control', 'private');
     $resp->headers->set('Content-Length', strlen($res));
     $resp->headers->set('Content-Type', 'application/force-download');
     $resp->headers->set('Content-Disposition', sprintf('attachment; filename="%s-%s.xml"', date("Y-m-d"), $dataClass->getHostFromKey($key)));
     $resp->sendHeaders();
     $resp->setContent($res);
     $resp->sendContent();
     die;
 }
开发者ID:Barathi07,项目名称:Netopeer-GUI,代码行数:24,代码来源:DefaultController.php


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