Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Net::HTTP does not allow buffer size to be overridden in subclass [rt.cpan.org #25069]

Open
#38 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
perl
Domain
networking

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.

Description

Migrated from rt.cpan.org#25069 (status was 'open')

Requestors:

From [email protected] 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 [email protected] on 2017-01-25 21:40:44:

migrated queues: libwww-perl -> Net-HTTP
Dominant language
Perl
Stars
20
Forks
27
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from libwww-perl/Net-HTTP

All issues in libwww-perl/Net-HTTP

Similar issues

More Perl issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.