Skip Menu |

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

Report information
The Basics
Id: 114124
Status: open
Priority: 0/
Queue: HTTP-Server-Simple

People
Owner: Nobody in particular
Requestors: larsss31 [...] gmail.com
Cc:
AdminCc:

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



Subject: Package built from net_server subclass has wrong startup parameters
Date: Mon, 2 May 2016 13:49:03 +0200
To: bug-HTTP-Server-Simple [...] rt.cpan.org
From: larss <larsss31 [...] gmail.com>
Hi, when passing subclass to Net::Server to H::S::S via net_server method, a package is built and then run. Arguments passed are the explicit port (port => $self->port) and the array of options passed to the method itself. Problem is that, as the Net::Server “run” method is executed, it tries to parse input parameters, but the “port=>$self->port” part messes up the initialization Here is a Data::Dumper of @_ with and without the port; in the former, package is run with $pkg->run( port => $self->port, @_ ); $VAR1 = [ ‘MyServer::NetServer0', 'port', '8080', { 'group' => 5001, 'max_servers' => 80, 'log_level' => 4, 'max_requests' => 1000, 'user' => 5001, 'port' => 17000 } ]; in the latter $pkg->run( @_ ); $VAR1 = [ ‘MyServer::NetServer0', { 'group' => 5001, 'max_servers' => 80, 'log_level' => 4, 'max_requests' => 1000, 'user' => 5001, 'port' => 17000 } ]; In the former case, option passed in the hash are ignored and server is started on the 8080 port. In the latter, everything goes as predicted, with options taken into account. Thanks, larss
Could you provide a test script? I couldn't reproduce this using Net::Server::Single. package MyServer; use base 'HTTP::Server::Simple'; sub net_server { "Net::Server::Single" } package main; my $PORT = 40000 + int(rand(10000)); my $server = MyServer->new(); $server->port($PORT); eval { local $SIG{ALRM} = sub { die }; alarm 1; $server->run; }; use Data::Dumper; print Dumper $server; prints: $VAR1 = bless( { 'port' => 45994, 'family' => 2 }, 'MyServer' );
Subject: Re: [rt.cpan.org #114124] Package built from net_server subclass has wrong startup parameters
Date: Wed, 3 Jan 2018 17:08:21 +0100
To: bug-HTTP-Server-Simple [...] rt.cpan.org
From: larss <larsss31 [...] gmail.com>
The problem lies in line 306 of the package https://github.com/bestpractical/http-server-simple/blob/master/lib/HTTP/Server/Simple.pm <https://github.com/bestpractical/http-server-simple/blob/master/lib/HTTP/Server/Simple.pm> when called with $pkg->run( port => $self->port, @_ ); the just built package is run with the port specified in that fashion (port => $self->port). This is somehow misinterpreted, or ignores completely the fact that, in the @_ array, the port parameter is enclosed in the configuration file passed to Net::Server through the conf_file option. As specified, modifying the running bit with: $pkg->run( @_ ); the configuration file is taken into account completely and works as expected. Thanks, larss Show quoted text
> On 26 Apr 2017, at 06:44, Perl Ancar via RT <bug-HTTP-Server-Simple@rt.cpan.org> wrote: > > <URL: https://rt.cpan.org/Ticket/Display.html?id=114124 > > > Could you provide a test script? I couldn't reproduce this using Net::Server::Single. > > package MyServer; > use base 'HTTP::Server::Simple'; > sub net_server { "Net::Server::Single" } > > package main; > my $PORT = 40000 + int(rand(10000)); > my $server = MyServer->new(); > $server->port($PORT); > eval { > local $SIG{ALRM} = sub { die }; > alarm 1; > $server->run; > }; > use Data::Dumper; print Dumper $server; > > prints: > > $VAR1 = bless( { > 'port' => 45994, > 'family' => 2 > }, 'MyServer' ); >