LP#1406025: Return 404 or 410 HTTP status codes for bibs
authorDan Scott <dscott@laurentian.ca>
Sun, 28 Dec 2014 01:25:50 +0000 (20:25 -0500)
committerBen Shum <bshum@biblio.org>
Mon, 16 Feb 2015 09:29:38 +0000 (04:29 -0500)
If a record has been deleted, return a 410 Gone status code; if it doesn't
exist at all, return a 404 Not Found code.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Signed-off-by: Ben Shum <bshum@biblio.org>

Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm

index 8170b6d..cf8ea00 100644 (file)
@@ -1,6 +1,6 @@
 package OpenILS::WWW::EGCatLoader;
 use strict; use warnings;
-use Apache2::Const -compile => qw(OK DECLINED FORBIDDEN HTTP_INTERNAL_SERVER_ERROR REDIRECT HTTP_BAD_REQUEST);
+use Apache2::Const -compile => qw(OK DECLINED FORBIDDEN HTTP_GONE HTTP_INTERNAL_SERVER_ERROR REDIRECT HTTP_BAD_REQUEST HTTP_NOT_FOUND);
 use OpenSRF::Utils::Logger qw/$logger/;
 use OpenILS::Utils::CStoreEditor qw/:funcs/;
 use OpenILS::Utils::Fieldmapper;
@@ -140,6 +140,16 @@ sub load_record {
 
     $cstore->kill_me;
 
+    # Shortcut and help the machines with a 410 Gone status code
+    if ($self->ctx->{bib_is_dead}) {
+        return Apache2::Const::HTTP_GONE;
+    }
+
+    # Shortcut and help the machines with a 404 Not Found status code
+    if (!$ctx->{bre_id}) {
+        return Apache2::Const::HTTP_NOT_FOUND;
+    }
+
     if (
         $ctx->{get_org_setting}->
             ($org, "opac.fully_compressed_serial_holdings")