Bugzilla – Attachment 187030 Details for
Bug 30614
check-url-quick gives false error 404
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30614: Fallback to a GET request if HEAD returns error status
Bug-30614-Fallback-to-a-GET-request-if-HEAD-return.patch (text/plain), 2.96 KB, created by
Aleisha Amohia
on 2025-09-29 04:17:20 UTC
(
hide
)
Description:
Bug 30614: Fallback to a GET request if HEAD returns error status
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2025-09-29 04:17:20 UTC
Size:
2.96 KB
patch
obsolete
>From d148f122000e2aab2ed1a325c645ab7badbddfe4 Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleisha@catalyst.net.nz> >Date: Fri, 12 Sep 2025 04:30:12 +0000 >Subject: [PATCH] Bug 30614: Fallback to a GET request if HEAD returns error > status > >This enhancement makes a GET request as a fallback if HEAD returns an error status. > >This doesn't fix all of the errors produced by the sample error MARC attached - any further support is welcomed. > >To test: >1. Download MARC. Go to Cataloguing in the staff interface and stage the MARC file for import, then import. >2. Run the URL check job and confirm erroring URLs > >perl misc/cronjobs/check-url-quick.pl -v > test.txt >grep -E "tand|wiley|natlib|cold|canterbury" test.txt > >3. Apply patch and restart services >4. Repeat step 2 and notice 2 of the URLs are now returning 200 OK status codes. > >Sponsored-by: Earth Sciences New Zealand >--- > misc/cronjobs/check-url-quick.pl | 20 ++++++++++++++++++-- > 1 file changed, 18 insertions(+), 2 deletions(-) > >diff --git a/misc/cronjobs/check-url-quick.pl b/misc/cronjobs/check-url-quick.pl >index 78b8adc229a..6483b0b2849 100755 >--- a/misc/cronjobs/check-url-quick.pl >+++ b/misc/cronjobs/check-url-quick.pl >@@ -27,6 +27,9 @@ use Koha::Biblios; > use AnyEvent; > use AnyEvent::HTTP qw( http_request ); > use Encode qw( encode_utf8 ); >+use HTTP::Request; >+use LWP::UserAgent; >+use URI; > > my ( $verbose, $help, $html ) = ( 0, 0, 0 ); > my ( $host, $host_intranet ) = ( '', '' ); >@@ -108,8 +111,21 @@ sub check_all_url { > sub { > my ( undef, $hdr ) = @_; > $count--; >- report( $hdr, $biblionumber, $url ) >- if $hdr->{Status} !~ /^2/ || $verbose; >+ if ( $hdr->{Status} !~ /^2/ ) { >+ 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 ) { >+ 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 ); >+ my $reason = substr( $response->status_line, 3 ); >+ report( { Status => $status_code, Reason => $reason }, $biblionumber, $url ) >+ if !$response->is_success || $verbose; >+ } > }, > ); > } >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 30614
:
186380
|
186381
| 187030