Add API to get buffer size for file transfers

This commit is contained in:
iliajie
2022-11-21 21:07:00 +02:00
parent 61000107b8
commit e9d58bdd42
4 changed files with 19 additions and 6 deletions

File diff suppressed because one or more lines are too long

View File

@@ -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 $_;
}

View File

@@ -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);

View 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