AnyEvent-Net-Curl-Queued
view release on metacpan or search on metacpan
inc/Test/HTTP/AnyEvent/Server.pm view on Meta::CPAN
package Test::HTTP::AnyEvent::Server;
# ABSTRACT: the async counterpart to Test::HTTP::Server
use feature qw(state switch);
use strict;
use utf8;
use warnings qw(all);
use AnyEvent;
use AnyEvent::Handle;
use AnyEvent::Log;
use AnyEvent::Socket;
use AnyEvent::Util;
use HTTP::Headers;
use HTTP::Request;
use HTTP::Response;
use Moo;
use MooX::Types::MooseLike::Base qw(:all);
use POSIX;
no if ($] >= 5.017010), warnings => q(experimental);
#$AnyEvent::Log::FILTER->level('debug');
our $VERSION = '0.007'; # VERSION
my %pool;
has address => (is => 'ro', isa => Str, default => sub { '127.0.0.1' }, writer => 'set_address');
has port => (is => 'ro', isa => Int, writer => 'set_port');
has maxconn => (is => 'ro', isa => Int, default => sub { 10 });
has timeout => (is => 'ro', isa => Int, default => sub { 60 });
has disable_proxy => (is => 'ro', isa => Bool, default => sub { 1 });
has forked => (is => 'ro', isa => Bool, default => sub { 0 });
has forked_pid => (is => 'ro', isa => Int, writer => 'set_forked_pid');
has server => (is => 'ro', isa => Ref, writer => 'set_server');
sub BUILD {
my ($self) = @_;
## no critic (RequireLocalizedPunctuationVars)
@ENV{qw(no_proxy http_proxy ftp_proxy all_proxy)} = (q(localhost,127.0.0.1), (q()) x 3)
if $self->disable_proxy;
unless ($self->forked) {
$self->set_server(
$self->start_server(sub {
my (undef, $address, $port) = @_;
$self->set_address($address);
$self->set_port($port);
AE::log info =>
"bound to http://$address:$port/";
})
);
} else {
my ($rh, $wh) = portable_pipe;
given (fork) {
when (undef) {
( run in 0.987 second using v1.01-cache-2.11-cpan-5837b0d9d2c )