Skip Menu |

This queue is for tickets about the Net-HTTP CPAN distribution.

Report information
The Basics
Id: 25069
Status: resolved
Priority: 0/
Queue: Net-HTTP

People
Owner: Nobody in particular
Requestors: dpisoni [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Net::HTTP does not allow buffer size to be overridden in subclass
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( @_ ); }
migrated queues: libwww-perl -> Net-HTTP