2005-12-05 21:35:07 +08:00
|
|
|
package HTTPTest;
|
|
|
|
|
|
|
|
use strict;
|
2008-11-13 04:18:27 +08:00
|
|
|
use warnings;
|
2005-12-05 21:35:07 +08:00
|
|
|
|
|
|
|
use HTTPServer;
|
2014-09-24 22:40:03 +08:00
|
|
|
use WgetTests;
|
2006-01-24 20:15:58 +08:00
|
|
|
|
2007-07-12 14:10:48 +08:00
|
|
|
our @ISA = qw(WgetTest);
|
2006-01-24 20:15:58 +08:00
|
|
|
my $VERSION = 0.01;
|
2005-12-05 21:35:07 +08:00
|
|
|
|
|
|
|
{
|
2014-11-01 17:06:26 +08:00
|
|
|
my %_attr_data = ( # DEFAULT
|
2005-12-05 21:35:07 +08:00
|
|
|
);
|
2008-11-13 19:29:59 +08:00
|
|
|
|
2007-06-14 23:59:23 +08:00
|
|
|
sub _default_for
|
|
|
|
{
|
|
|
|
my ($self, $attr) = @_;
|
2005-12-05 21:35:07 +08:00
|
|
|
return $_attr_data{$attr} if exists $_attr_data{$attr};
|
2007-06-14 23:59:23 +08:00
|
|
|
return $self->SUPER::_default_for($attr);
|
|
|
|
}
|
2005-12-05 21:35:07 +08:00
|
|
|
|
2008-11-13 19:29:59 +08:00
|
|
|
sub _standard_keys
|
2007-06-14 23:59:23 +08:00
|
|
|
{
|
2005-12-05 21:35:07 +08:00
|
|
|
my ($self) = @_;
|
2007-06-14 23:59:23 +08:00
|
|
|
($self->SUPER::_standard_keys(), keys %_attr_data);
|
|
|
|
}
|
2005-12-05 21:35:07 +08:00
|
|
|
}
|
2008-11-13 19:29:59 +08:00
|
|
|
|
2014-11-01 17:06:26 +08:00
|
|
|
sub _setup_server
|
|
|
|
{
|
2008-06-12 17:18:35 +08:00
|
|
|
my $self = shift;
|
2014-11-01 17:06:26 +08:00
|
|
|
$self->{_server} = HTTPServer->new(LocalAddr => 'localhost',
|
|
|
|
ReuseAddr => 1)
|
|
|
|
or die "Cannot create server!!!";
|
2008-06-12 17:18:35 +08:00
|
|
|
}
|
2005-12-05 21:35:07 +08:00
|
|
|
|
2014-11-01 17:06:26 +08:00
|
|
|
sub _launch_server
|
|
|
|
{
|
|
|
|
my $self = shift;
|
2006-05-29 17:15:06 +08:00
|
|
|
my $synch_func = shift;
|
2005-12-05 21:35:07 +08:00
|
|
|
|
2014-11-01 17:06:26 +08:00
|
|
|
$self->{_server}->run($self->{_input}, $synch_func);
|
2008-06-12 17:18:35 +08:00
|
|
|
}
|
|
|
|
|
2014-11-01 17:06:26 +08:00
|
|
|
sub _substitute_port
|
|
|
|
{
|
2008-06-12 17:18:35 +08:00
|
|
|
my $self = shift;
|
2014-11-01 17:06:26 +08:00
|
|
|
my $ret = shift;
|
2008-06-12 17:18:35 +08:00
|
|
|
$ret =~ s/{{port}}/$self->{_server}->sockport/eg;
|
|
|
|
return $ret;
|
2005-12-05 21:35:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
1;
|
|
|
|
|
|
|
|
# vim: et ts=4 sw=4
|