AnyEvent-UserAgent

 view release on metacpan or  search on metacpan

lib/AnyEvent/UserAgent.pm  view on Meta::CPAN

		$self->cookie_jar->add_cookie_header($req);
	}

	for (qw(max_redirects inactivity_timeout request_timeout), @OPTIONS) {
		$opts->{$_} = $self->$_() unless exists($opts->{$_});
	}

	my ($grd, $tmr);

	if ($opts->{request_timeout}) {
		$tmr = AE::timer $opts->{request_timeout}, 0, sub {
			undef($grd);
			$cb->($opts, undef, {Status => 597, Reason => 'Request timeout'});
		};
	}
	$grd = AnyEvent::HTTP::http_request(
		$req->method,
		$req->uri,
		headers => {map { $_ => scalar($hdrs->header($_)) } $hdrs->header_field_names},
		body    => $req->content,
		recurse => 0,

t/02-options-1.t  view on Meta::CPAN


	*AnyEvent::HTTP::http_request = sub {
		my $cb = pop();
		my (undef, undef, %opts) = @_;

		ok $opts{timeout} == $TIMEOUT;
		ok $cnt <= $MAX_REDIRECTS;

		$cnt++;

		my $t; $t = AE::timer 0.1, 0, sub {
			undef($t);
			$cb->('', {
				Status   => 302,
				Location => 'http://example.com/',
			});
		};
	};
}

my $ua = AnyEvent::UserAgent->new(

t/05-timeout.t  view on Meta::CPAN


our $TIMEOUT = 0.5;

{
	no warnings 'prototype';
	no warnings 'redefine';

	*AnyEvent::HTTP::http_request = sub {
		my $cb = pop();

		my $t; $t = AE::timer $TIMEOUT + 10, 0, sub {
			undef($t);
			$cb->('', {
				Status => 200,
				Reason => 'OK',
			});
		};
	};
}

my $ua = AnyEvent::UserAgent->new(



( run in 1.218 second using v1.01-cache-2.11-cpan-49f99fa48dc )