https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30614 --- Comment #11 from David Cook <dcook@prosentient.com.au> --- Comment on attachment 187030 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=187030 Bug 30614: Fallback to a GET request if HEAD returns error status Review of attachment 187030: --> (https://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=30614&attachment=187030) ----------------------------------------------------------------- ::: misc/cronjobs/check-url-quick.pl @@ +115,5 @@
+ my $request = HTTP::Request->new( 'GET' => $url ); + my $ua = LWP::UserAgent->new; + $ua->agent($user_agent); + my $response = $ua->request($request); + if ( $response->is_redirect ) {
I think that LWP::UserAgent follows redirects by default, so I don't think this code would be triggered? For instance, if you curl https://google.com you'll get a 301 but if you use LWP::UserAgent with that HTTP::Request GET, you'll get a 200. It's not clear to me at a glance if AnyEvent::HTTP::http_request follows redirects by default or not. At a glance, it looks like maybe not. @@ +120,5 @@
+ my $redirect_url = $response->header('Location'); + $redirect_url = URI->new_abs( $redirect_url, $url ); + $response = $ua->get($redirect_url); + } + my $status_code = substr( $response->status_line, 0, 3 );
You can just use $response->code() here. @@ +121,5 @@
+ $redirect_url = URI->new_abs( $redirect_url, $url ); + $response = $ua->get($redirect_url); + } + my $status_code = substr( $response->status_line, 0, 3 ); + my $reason = substr( $response->status_line, 3 );
You can use $response->message() here. -- You are receiving this mail because: You are watching all bug changes.