Skip to content

Commit

Permalink
Add an example script to demonstrate handler order
Browse files Browse the repository at this point in the history
  • Loading branch information
oalders committed Apr 11, 2019
1 parent d145112 commit 4673989
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions examples/handler-order.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env perl

use strict;
use warnings;
use feature qw( say );

use LWP::UserAgent;
my $ua = LWP::UserAgent->new;

my @phases = (
'request_preprepare', 'request_prepare',
'request_send', 'response_header',
'response_data', 'response_done',
'response_redirect',
);

for my $phase (@phases) {
$ua->add_handler($phase => sub { say "$phase"; return undef; });
}

$ua->get('http://example.com');

0 comments on commit 4673989

Please sign in to comment.