Skip to content

Commit f69d463

Browse files
neilboalders
authored andcommitted
Increased read() buffer size from 2048 to 8192, when reading form data
This was suggested by a user, who said it gave "much better performance", in 2015. RT#105184 GH#59
1 parent 6ea9615 commit f69d463

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

Changes

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ Revision history for HTTP-Message
33
{{$NEXT}}
44
- We now don't consider the Content-Location header when asked
55
for the base URI. RFC 7231 says we shouldn't. (GH#51) (Neil Bowers)
6+
- Increased the (max) buffer size for read() when processing form data,
7+
from 2048 to 8192. This was suggested in RT#105184, as it improved
8+
performance for them. (GH#59) (Neil Bowers)
69

710
6.40 2022-10-12 15:45:52Z
811
- Fixed two typos in the doc, originally reported by FatherC

lib/HTTP/Request/Common.pm

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use warnings;
66
our $VERSION = '6.41';
77

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

1011
use Exporter 5.57 'import';
1112

@@ -253,7 +254,7 @@ sub form_data # RFC1867
253254
binmode($fh);
254255
}
255256
my $buflength = length $buf;
256-
my $n = read($fh, $buf, 2048, $buflength);
257+
my $n = read($fh, $buf, $READ_BUFFER_SIZE, $buflength);
257258
if ($n) {
258259
$buflength += $n;
259260
unshift(@parts, ["", $fh]);

t/common-req.t

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ $_ = join("", @chunks);
231231
#note int(@chunks), " chunks, total size is ", length($_), " bytes\n";
232232

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

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

0 commit comments

Comments
 (0)