@param Request         $request
@param ResponseFactory $response

@return BinaryFileResponse
323836
public function download(Request $request, ResponseFactory $response): BinaryFileResponse
    {
        $data = $this->validate($request, [
            'path'     => 'required',
            'filename' => 'required',
        ]);

        return $response->download(
            $data['path'],
            $data['filename']
        )->deleteFileAfterSend($shouldDelete = true);
    }
463200
public function executeFilters(Request $request, Response $response)
    {
        $middlewares = $this->filterMiddleware(Filter::class);

        foreach ($middlewares as $middleware) {
            if (($returnResponse = $middleware->doFilter($request, $response)) !== null) {
                return $returnResponse;
            }
            unset($returnResponse);
        }

        unset($middlewares);
    }
238068
private function getAudioResponse(Request $request, Response $response)
    {
        try {
            // First, we try to get a MP3 file directly.
            if (!empty($request->getQueryParam('from')) || !empty($request->getQueryParam('to'))) {
                throw new Exception('Force convert when we need to seek.');
            }

            if ($this->config->stream) {
                $this->video = $this->video->withFormat('mp3');

                return $this->getStream($request, $response);
            } else {
                $this->video = $this->video->withFormat('mp3[protocol=https]/mp3[protocol=http]');

                $urls = $this->video->getUrl();

                return $response->withRedirect($urls[0]);
            }
        } catch (PasswordException $e) {
            $frontController = new FrontController($this->container);

            return $frontController->password($request, $response);
        } catch (Exception $e) {
            // If MP3 is not available, we convert it.
            $this->video = $this->video->withFormat($this->defaultFormat);

            return $this->getConvertedAudioResponse($request, $response);
        }
    }
1143100
public function executeTerminators(Request $request, Response $response): Response
    {
        $middlewares = $this->filterMiddleware(Terminator::class);

        foreach ($middlewares as $middleware) {
            $response = $middleware->doTerminate($request, $response);
        }

        unset($middlewares);

        return $response;
    }
301654
static function dropzoneUpload ($request, $response)
  {
    $ds = DIRECTORY_SEPARATOR;
    $storeFolder = self::TEMP_STORE_FOLDER_NAME;
    $storePath = sys_get_temp_dir().$ds.$storeFolder;

    if (!is_dir($storePath))
      mkdir($storePath);

    $file = "";
    foreach ($request->getUploadedFiles() as $oFile)
    {
      $filename = $oFile->getClientFilename ();
      $filePath = $storePath.$ds.$filename;
      $oFile->moveTo($filePath);
      $file = $filePath;
    }
    return Http::jsonResponse ($response,$file);
  }
276241
public function responseToResultTransformer(ResponseInterface $response, RequestInterface $request)
    {
        $data = json_decode($response->getBody(), true);

        return new Result($data);
    }
1247287
public function execute(ServerRequestInterface $request, ResponseInterface $response)
    {
        try {
            return $this->router->start($request, $response);
        } catch (\Exception $e) {
            $this->logger->warning('Unexpected exception: ' . $e->getMessage());
            $this->logger->debug($e->__toString());

            return $response->withStatus(500)
                ->withBody(new StringStream($e->getMessage()));
        }
    }
616909
public function copyBulkAction(Request $request, $class)
    {
        $query = $request->query->all();
        $serializer = $this->serializer;
        $options = $this->options['copyBulk'];

        if (isset($query['options'])) {
            $options = $query['options'];
        }

        $copies = $this->crud->copyBulk(
            $class,
            $this->decodeIdsString($request, $class),
            $options
        );

        return new JsonResponse(array_map(function ($copy) use ($serializer, $options) {
            return $serializer->serialize($copy, $this->options['get']);
        }, $copies), 200);
    }
459086
public function processPhpFile($event, $request, $response, $file)
    {
        if(!$this->php_engine){
            $response->statusCode = 403;
            $response->body = "php engine disabled";
            return ;
        }
        
        if(!$response->headers->has('Content-type')) {
            if($response->charset === null && $this->default_charset){
                $response->charset = $this->default_charset;
            }
            
            $response->mimeType = $this->default_content_type;
        }
        
        $_POST = $request->_POST;
        $_GET = $request->_GET;
        $_FILES = $request->_FILES;
        $_COOKIE = $request->_COOKIE;
        $_SERVER = $request->_SERVER;
        
        ob_start();        
        include $file;
        
        if($response->gzip && $request->gzipSupport()){
            $response->headers->set('Content-Encoding', 'gzip');
            $response->body = gzencode(ob_get_clean());
        }else{
            $response->body = ob_get_clean();
        }
        
        return ;
    }
878321
public function handleResponse(Request $request, Response $response)
    {
        if ($response->getStatusCode() == 422) {
            $errors = $response->getOriginalContent()['validation_errors'];

            throw new HttpResponseException(
                redirect()->back()->withInput($request->input())->withErrors($errors)
            );
        }

        if ($response->getStatusCode() == 403) {
            abort(403);
        }

        return $response->isNotFound() ? abort(404) : $response->getOriginalContent();
    }
428053
private function executePassiveActions(Request $request, Response $response): Response
    {
        foreach ($this->getRouter()->getConfiguration()->getPassiveActions() as $action => $whitelist) {
            $activeAction = $this->getRouter()->getActionAlias($request);

            if (!in_array($activeAction, $whitelist) && !in_array('all', $whitelist)) {
                continue;
            }

            if (in_array('-' . $activeAction, $whitelist) && in_array('all', $whitelist)) {
                continue;
            }

            $route = $this->getRouter()->getAliasedRoute($action, [], Router::PASSIVE_ACTION);

            if (!method_exists($route->getController(), $route->getAction())) {
                throw new ActionNotFoundException($action . ' passive action is present in registry, but can\'t be found or is improperly configured.');
            }

            $controllerName = $route->getController();
            $controller = new $controllerName($this->drivers, $request, $response);
            $response = $controller->{$route->getAction()}(...$route->getActionParams());
        }

        return $response;
    }
1271346
public function zipAction(Request $request)
    {
        $filename = basename($request->get('filename'));

        $path = $this->container->getParameter('phlexible_media_manager.temp_dir');
        $filepath = $path.'/'.$filename;

        if (!$filename || !file_exists($filepath)) {
            return $this->createNotFoundException();
        }

        $response = new BinaryFileResponse($filepath, 200, array('Content-Type' => 'application/zip'));
        $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT);

        return $response;
    }
203840
public function fileAction(Request $request)
    {
        $fileId = $request->get('id');

        $volumeManager = $this->get('phlexible_media_manager.volume_manager');
        $volume = $volumeManager->getByFileId($fileId);
        $file = $volume->findFile($fileId);

        $filepath = $file->getPhysicalPath();
        $filename = $file->getName();

        $response = new BinaryFileResponse($filepath, 200, array('Content-Type' => $file->getMimeType()));
        $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $filename);

        return $response;
    }
468866
function process_response($request, $response)
    {
        if (! $request->user->isAnonymous()) {
            $request->session->setData($this->session_key, $request->user->id);
        }
        return $response;
    }
1371358
public function addResponse(RequestInterface $request, ResponseInterface $response): self
    {
        $new = clone $this;
        $new->responses->attach($request, $response);

        return $new;
    }
416928
public function httpGet(RequestInterface $request, ResponseInterface $response)
    {
        $node = $this->server->tree->getNodeForPath($request->getPath());
        if ($node instanceof DAV\IFile) {
            return;
        }

        $subRequest = clone $request;
        $subRequest->setMethod('PROPFIND');

        $this->server->invokeMethod($subRequest, $response);

        return false;
    }
1290348
protected function setUriHeader(Response $response, Request $request)
    {
        $response->header('X-PJAX-URL', $request->getRequestUri());

        return $this;
    }