File assets should always give IO::File::WithPath objects to PSGI, instead of the current redirecting or streaming behavior. (#11688)
New API method: WebGUI::Response::sendFile; it, as appropriate, calls setRedirect or setStreamedFile, depending on enableStreamingUploads config var. setStreamedFile now kicks off the XSendfile process. File.pm now uses this instead of trying to set both a redirect and a stream. IO::File::WithPath blows up if a file doesn't exist so this raises an exception now. The http now no longer insist that '0' is not a valid filename to stream. site.psgi, depending on enableStreamingUploads, enables either the Static or XSendfile middleware.
This commit is contained in:
parent
96bb194402
commit
7a994b59ce
6 changed files with 184 additions and 25 deletions
|
|
@ -176,19 +176,6 @@ sub handler {
|
|||
else {
|
||||
$output = dispatch($session, getRequestedAssetUrl($session));
|
||||
}
|
||||
|
||||
my $filename = $session->response->getStreamedFile();
|
||||
if ((defined $filename) && ($config->get("enableStreamingUploads") eq "1")) {
|
||||
my $ct = guess_media_type($filename);
|
||||
my $oldContentType = $request->content_type($ct);
|
||||
if ($request->sendfile($filename) ) {
|
||||
return; # TODO - what should we return to indicate streaming?
|
||||
}
|
||||
else {
|
||||
$request->content_type($oldContentType);
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue