Skip to content

Increased read() buffer size from 2048 to 8192, when reading form data #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Revision history for HTTP-Message
{{$NEXT}}
- We now don't consider the Content-Location header when asked
for the base URI. RFC 7231 says we shouldn't. (GH#51) (Neil Bowers)
- Increased the (max) buffer size for read() when processing form data,
from 2048 to 8192. This was suggested in RT#105184, as it improved
performance for them. (GH#59) (Neil Bowers)

6.40 2022-10-12 15:45:52Z
- Fixed two typos in the doc, originally reported by FatherC
Expand Down
3 changes: 2 additions & 1 deletion lib/HTTP/Request/Common.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use warnings;
our $VERSION = '6.41';

our $DYNAMIC_FILE_UPLOAD ||= 0; # make it defined (don't know why)
our $READ_BUFFER_SIZE = 8192;

use Exporter 5.57 'import';

Expand Down Expand Up @@ -253,7 +254,7 @@ sub form_data # RFC1867
binmode($fh);
}
my $buflength = length $buf;
my $n = read($fh, $buf, 2048, $buflength);
my $n = read($fh, $buf, $READ_BUFFER_SIZE, $buflength);
if ($n) {
$buflength += $n;
unshift(@parts, ["", $fh]);
Expand Down
2 changes: 1 addition & 1 deletion t/common-req.t
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ $_ = join("", @chunks);
#note int(@chunks), " chunks, total size is ", length($_), " bytes\n";

# should be close to expected size and number of chunks
cmp_ok(abs(@chunks - 15), '<', 3);
cmp_ok(abs(@chunks - 6), '<', 3);
cmp_ok(abs(length($_) - 26589), '<', 20);

$r = POST 'http://www.example.com';
Expand Down