Commits

Toby Inkster committed f6fa3e5

Still not working; commiting for posterity before I try a slightly different approach.

Comments (0)

Files changed (2)

examples/assert.pl

-use AnyEvent::Impl::Perl;
+use EV;
 use Web::Magic::Async;
 
 my $a = Web::Magic::Async
 	->new(GET => 'http://www.google.co.uk/adgawertgwretgwrtgw')
 	->assert_response(success => sub {$_->is_success})
 	->do_request;
-	
+
 warn length($a->content);
 warn length($b->content);

lib/Web/Magic/Async.pm

 		croak "Need to perform HTTP request, but it is cancelled.";
 	}
 	
-	unless (exists $self->_async->{got_head})
+	unless (exists $self->_async->{got_body})
 	{
 		my $req = $self->_final_request_object(
 			User_Agent => $self->_ua_string,
 {
 	my ($self, %extra_headers) = @_;
 	
+	return $self->_stash->{response}
+		if $self->_stash->{response};
+		
 	$self->do_request(%extra_headers)
 		unless exists $self->_async->{got_body};
 	
 {
 	my ($self) = @_;
 
-	if ($self->_stash->{response})
-	{
-		return $self->_stash->{response}->headers;
-	}
+	return $self->_stash->{response}->headers
+		if $self->_stash->{response};
 
 	$self->do_request
 		unless exists $self->_async->{got_head};