mirror of
https://github.com/webmin/webmin.git
synced 2026-02-03 14:13:29 +00:00
Add API to get buffer size for file transfers
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -25,7 +25,7 @@ print "Content-Disposition: attachment; filename=\"$name$ext\"\n";
|
||||
print "Content-Length: $size\n\n";
|
||||
open (FILE, "< $file") or die "can't open $file: $!";
|
||||
binmode FILE;
|
||||
local $/ = \2048000;
|
||||
local $/ = \&get_buffer_size_binary();
|
||||
while (<FILE>) {
|
||||
print $_;
|
||||
}
|
||||
|
||||
@@ -53,8 +53,7 @@ if ($ENV{'PATH_INFO'}) {
|
||||
print "Content-type: application/zip\n\n";
|
||||
open(FILE, "<$temp");
|
||||
unlink($temp);
|
||||
my $bs = &get_buffer_size();
|
||||
while(read(FILE, $buffer, $bs)) {
|
||||
while(read(FILE, $buffer, &get_buffer_size_binary())) {
|
||||
print("$buffer");
|
||||
}
|
||||
close(FILE);
|
||||
@@ -85,7 +84,7 @@ if ($ENV{'PATH_INFO'}) {
|
||||
print "Content-length: $st[7]\n";
|
||||
print "X-Content-Type-Options: nosniff\n";
|
||||
print "Content-type: $type\n\n";
|
||||
while(read(FILE, $buffer, 1000000)) {
|
||||
while(read(FILE, $buffer, &get_buffer_size_binary())) {
|
||||
print("$buffer");
|
||||
}
|
||||
close(FILE);
|
||||
|
||||
@@ -12024,7 +12024,8 @@ return &has_command("python3") || &has_command("python30") ||
|
||||
|
||||
=head2 get_buffer_size
|
||||
|
||||
Returns the buffer size for read/write operations
|
||||
Returns the buffer size for read/write
|
||||
operations (def. 32 KiB)
|
||||
|
||||
=cut
|
||||
sub get_buffer_size
|
||||
@@ -12034,6 +12035,19 @@ my %miniserv;
|
||||
return $miniserv{'bufsize'} || 32768;
|
||||
}
|
||||
|
||||
=head2 get_buffer_size_binary
|
||||
|
||||
Returns the buffer size for read/write operations
|
||||
in uploads/downloads (def. ~ 6 MB)
|
||||
|
||||
=cut
|
||||
sub get_buffer_size_binary
|
||||
{
|
||||
my %miniserv;
|
||||
&get_miniserv_config(\%miniserv);
|
||||
return $miniserv{'bufsize_binary'} || (65536 * 100);
|
||||
}
|
||||
|
||||
=head2 get_webprefix
|
||||
|
||||
Returns ready to use webprefix
|
||||
|
||||
Reference in New Issue
Block a user