libwww-perl / libwww-perl/Net-HTTP
Net::HTTP does not allow buffer size to be overridden in subclass [rt.cpan.org #25069]
Open
Nobody has claimed this yet.
- Dominant language
- Perl
- Stars
- 20
- Forks
- 27
- PR merge metrics
- No merged PRs in 30d
Description
Migrated from rt.cpan.org#25069 (status was 'open')
Requestors:
- dpisoni@cpan.org
From dpisoni@cpan.org on 2007-02-21 22:00:19:
In Net::HTTP, read_response_headers() uses the function my_readline() to do it's dirty-work.
Under the hood, my_readline() calls sysread() with a HARD-CODED size of 1024. Ideally, this
should be an option, or otherwise parameterized. Alternately, it would make sense to
replace my_readline() in a subclass, but this is impossible since it is called as a function. One
would need to replace read_response_headers() entirely in a subclass if one wanted to
change the behavior here (to capture a larger buffer in the first read, cutting down on
latency.) Alternately, one could redefine the my_readline() function. The last two options are
terrible designs, since they involve cloning the existing code and replacing only a small bit,
and may result in future incompatibilities.
my $n = $self->sysread($_, 1024, length);
I suggest you expose or otherwise parameterize this currently hard-coded value.
Here is my current (nasty) workaround in a subclass:
package MyNetHTTP;
use base 'Net::HTTP';
sub my_sysread {
my $self = shift;
$_[1] = $READ_BUFFER_LENGTH;
$self->SUPER::sysread(@_);
}
sub read_response_headers {
my $self = shift;
local *sysread = *my_sysread;
$self->SUPER::read_response_headers( @_ );
}
From ether@cpan.org on 2017-01-25 21:40:44:
migrated queues: libwww-perl -> Net-HTTP
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing read_response_headers() through my_readline() and the sysread() call described in the issue, including the hard-coded 1024-byte size. The work is done when the buffer size can be configured or the read helper can be overridden cleanly by a subclass without duplicating read_response_headers().
Written by the indexing model from the issue text.
Assessment
- Tech stack
- perl
- Domain
- networking
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100