diff --git a/module/VuFind/src/VuFind/Harvester/OAI.php b/module/VuFind/src/VuFind/Harvester/OAI.php
index 648ba49f16d297ceb72c4fe31a26b9a0bb0b0fd3..27db58c7321800de90c9e6d201988ab517dcb92a 100644
--- a/module/VuFind/src/VuFind/Harvester/OAI.php
+++ b/module/VuFind/src/VuFind/Harvester/OAI.php
@@ -495,7 +495,7 @@ class OAI
                     sleep($delay);
                 }
             } else if (!$result->isSuccess()) {
-                throw new \Exception('HTTP Error');
+                throw new \Exception('HTTP Error ' . $result->getStatusCode());
             } else {
                 // If we didn't get an error, we can leave the retry loop:
                 break;
@@ -558,8 +558,10 @@ class OAI
             $xml = $this->sanitizeXML($xml);
         }
 
-        // Parse the XML:
-        $result = simplexml_load_string($xml);
+        // Parse the XML (newer versions of LibXML require a special flag for
+        // large documents, and responses may be quite large):
+        $flags = LIBXML_VERSION >= 20900 ? LIBXML_PARSEHUGE : 0;
+        $result = simplexml_load_string($xml, null, $flags);
         if (!$result) {
             throw new \Exception("Problem loading XML: {$xml}");
         }