Fix hang on 500 from site during Find Available PDF

Find Available PDF has its own domain-based retry logic that predated
automatic 5xx retries in Zotero.HTTP, so disable the latter and fix some
bugs in the former.

Fixes #2700
This commit is contained in:
Dan Stillman 2022-10-29 04:07:19 -04:00
parent 77fdc8e40c
commit 7f91a0c1a8

View file

@ -2085,7 +2085,9 @@ Zotero.Attachments = new function(){
nextURL, nextURL,
{ {
responseType: 'blob', responseType: 'blob',
followRedirects: false followRedirects: false,
// Use our own error handling
errorDelayMax: 0
} }
); );
} }
@ -2096,11 +2098,13 @@ Zotero.Attachments = new function(){
noDelay = false; noDelay = false;
continue; continue;
} }
throw e;
} }
break; break;
} }
afterRequest(nextURL); afterRequest(nextURL);
if (!req) {
break;
}
if ([301, 302, 303, 307].includes(req.status)) { if ([301, 302, 303, 307].includes(req.status)) {
let location = req.getResponseHeader('Location'); let location = req.getResponseHeader('Location');
if (!location) { if (!location) {
@ -2158,7 +2162,7 @@ Zotero.Attachments = new function(){
} }
// If DOI resolves directly to a PDF, save it to disk // If DOI resolves directly to a PDF, save it to disk
if (contentType.startsWith('application/pdf')) { if (contentType && contentType.startsWith('application/pdf')) {
Zotero.debug("URL resolves directly to PDF"); Zotero.debug("URL resolves directly to PDF");
await Zotero.File.putContentsAsync(path, blob); await Zotero.File.putContentsAsync(path, blob);
await _enforcePDF(path); await _enforcePDF(path);
@ -2174,7 +2178,7 @@ Zotero.Attachments = new function(){
continue; continue;
} }
if (!url) { if (!url) {
Zotero.debug(`No PDF found on ${responseURL}`); Zotero.debug(`No PDF found on ${responseURL || pageURL}`);
continue; continue;
} }
if (isTriedURL(url)) { if (isTriedURL(url)) {