Bugzilla – Attachment 186381 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: [WIP] Fallback to a GET request if HEAD returns error status
Bug-30614-WIP-Fallback-to-a-GET-request-if-HEAD-re.patch (text/plain), 2.52 KB, created by
Aleisha Amohia
on 2025-09-12 04:35:21 UTC
(
hide
)
Description:
Bug 30614: [WIP] Fallback to a GET request if HEAD returns error status
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2025-09-12 04:35:21 UTC
Size:
2.52 KB
patch
obsolete
>From 90e15fbd9ee90470daa1b48efef1db226899b974 Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Fri, 12 Sep 2025 04:30:12 +0000 >Subject: [PATCH] Bug 30614: [WIP] Fallback to a GET request if HEAD returns > error status > >This is a WIP - feedback welcome. > >Sample MARC attached. Testing using: > >perl misc/cronjobs/check-url-quick.pl -v > test.txt >grep -E "tand|wiley|natlib|cold|canterbury" test.txt >--- > 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 88e2d431145..060682e97ef 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