@@ -766,10 +766,10 @@ sub handlers {
766766 my ($self , $phase , $o ) = @_ ;
767767 my @h ;
768768 if ($o -> {handlers } && $o -> {handlers }{$phase }) {
769- push (@h , @{$o -> {handlers }{$phase }});
769+ push (@h , map +{ callback => $_ }, @{$o -> {handlers }{$phase }});
770770 }
771771 if (my $conf = $self -> {handlers }{$phase }) {
772- push (@h , map { $_ -> { callback } } $conf -> matching($o ));
772+ push (@h , $conf -> matching($o ));
773773 }
774774 return @h ;
775775}
@@ -778,14 +778,14 @@ sub run_handlers {
778778 my ($self , $phase , $o ) = @_ ;
779779 if (defined (wantarray )) {
780780 for my $h ($self -> handlers($phase , $o )) {
781- my $ret = $h -> ($o , $self );
781+ my $ret = $h -> { callback } -> ($o , $self , $h );
782782 return $ret if $ret ;
783783 }
784784 return undef ;
785785 }
786786
787787 for my $h ($self -> handlers($phase , $o )) {
788- $h -> ($o , $self );
788+ $h -> { callback } -> ($o , $self , $h );
789789 }
790790}
791791
@@ -1336,15 +1336,15 @@ The possible values $phase are:
13361336
13371337=over
13381338
1339- =item request_preprepare => sub { my($request, $ua) = @_; ... }
1339+ =item request_preprepare => sub { my($request, $ua, $h ) = @_; ... }
13401340
13411341The handler is called before the C<request_prepare > and other standard
13421342initialization of of the request. This can be used to set up headers
13431343and attributes that the C<request_prepare > handler depends on. Proxy
13441344initialization should take place here; but in general don't register
13451345handlers for this phase.
13461346
1347- =item request_prepare => sub { my($request, $ua) = @_; ... }
1347+ =item request_prepare => sub { my($request, $ua, $h ) = @_; ... }
13481348
13491349The handler is called before the request is sent and can modify the
13501350request any way it see hit. This can for instance be used to add
@@ -1356,7 +1356,7 @@ request that is sent fully.
13561356The return value from the callback is ignored. Exceptions are
13571357not trapped and are propagated to the outer request method.
13581358
1359- =item request_send => sub { my($request, $ua) = @_; ... }
1359+ =item request_send => sub { my($request, $ua, $h ) = @_; ... }
13601360
13611361This handler get a chance of handling requests before it's sent to the
13621362protocol handlers. It should return an HTTP::Response object if it
@@ -1365,7 +1365,7 @@ wishes to terminate the processing; otherwise it should return nothing.
13651365The C<response_header > and C<response_data > handlers will not be
13661366invoked for this response, but the C<response_done > will be.
13671367
1368- =item response_header => sub { my($response, $ua) = @_; ... }
1368+ =item response_header => sub { my($response, $ua, $h ) = @_; ... }
13691369
13701370This handler is called right after the response headers have been
13711371received, but before any content data. The handler might set up
@@ -1377,21 +1377,21 @@ directly. This will initially be false if the $ua->request() method
13771377was called with a ':content_filename' or ':content_callbak' argument;
13781378otherwise true.
13791379
1380- =item response_data => sub { my($response, $ua, $data) = @_; ... }
1380+ =item response_data => sub { my($response, $ua, $h, $ data) = @_; ... }
13811381
13821382This handlers is called for each chunk of data received for the
13831383response. The handler might croak to abort the request.
13841384
13851385This handler need to return a TRUE value to be called again for
13861386subsequent chunks for the same request.
13871387
1388- =item response_done => sub { my($response, $ua) = @_; ... }
1388+ =item response_done => sub { my($response, $ua, $h ) = @_; ... }
13891389
13901390The handler is called after the response has been fully received, but
13911391before any redirect handling is attempted. The handler can be used to
13921392extract information or modify the response.
13931393
1394- =item response_redirect => sub { my($response, $ua) = @_; ... }
1394+ =item response_redirect => sub { my($response, $ua, $h ) = @_; ... }
13951395
13961396The handler is called in $ua->request after C<response_done > . If the
13971397handler return an HTTP::Request object we'll start over with processing
0 commit comments