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
|
|
@ -66,11 +66,22 @@ $response->status('200');
|
|||
|
||||
$http->setStreamedFile('');
|
||||
is($http->getStreamedFile, undef, 'set/get StreamedFile: false values return undef, empty string');
|
||||
$http->setStreamedFile(0);
|
||||
$http->setStreamedFile(undef);
|
||||
is($http->getStreamedFile, undef, 'set/get StreamedFile: false values return undef, empty string');
|
||||
|
||||
$http->setStreamedFile('/home/streaming');
|
||||
is($http->getStreamedFile, '/home/streaming', 'set/get StreamedFile: set specific location and get it');
|
||||
my $actual_file = $session->config->get('uploadsPath') . '/9e/a3/9ea37e148e517d4ae3d6326f691d848f/previous.gif'; # arbitrary file that exactually exists and hopefully will continue for a while
|
||||
$http->setStreamedFile( $actual_file );
|
||||
is($http->getStreamedFile, $actual_file, 'set/get StreamedFile: set specific location and get it');
|
||||
|
||||
do {
|
||||
eval {
|
||||
$http->setStreamedFile( $actual_file . '_but_actually_not_an_actual_file_because_someone_appended_a_bunch_of_bloody_garbage_to_it' );
|
||||
};
|
||||
my $e = WebGUI::Error->caught("WebGUI::Error::InvalidFile");
|
||||
my $errorMessage = $e->error;
|
||||
ok($errorMessage =~ m/No such file or directory/, "set/get StreamedFile: setting a non-existant file blows stuff up but that's okay because it's handled gracefully" );
|
||||
};
|
||||
|
||||
$http->setStreamedFile('');
|
||||
|
||||
####################################################
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue