Update MIME.getMIMETypeFromURL() for non-Bluebird HTTP.request()
This commit is contained in:
parent
e8dd1f7824
commit
7aa68a0f75
2 changed files with 37 additions and 30 deletions
|
@ -509,7 +509,8 @@ Zotero.Attachments = new function(){
|
||||||
return process(contentType, Zotero.MIME.hasNativeHandler(contentType));
|
return process(contentType, Zotero.MIME.hasNativeHandler(contentType));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Zotero.MIME.getMIMETypeFromURL(url, cookieSandbox).spread(process);
|
var args = yield Zotero.MIME.getMIMETypeFromURL(url, cookieSandbox);
|
||||||
|
return process(...args);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -327,9 +327,16 @@ Zotero.MIME = new function(){
|
||||||
* @param {Zotero.CookieSandbox} [cookieSandbox]
|
* @param {Zotero.CookieSandbox} [cookieSandbox]
|
||||||
* @return {Promise}
|
* @return {Promise}
|
||||||
*/
|
*/
|
||||||
this.getMIMETypeFromURL = function (url, cookieSandbox) {
|
this.getMIMETypeFromURL = async function (url, cookieSandbox) {
|
||||||
return Zotero.HTTP.promise("HEAD", url, { cookieSandbox: cookieSandbox, successCodes: false })
|
var xmlhttp = await Zotero.HTTP.request(
|
||||||
.then(function (xmlhttp) {
|
"HEAD",
|
||||||
|
url,
|
||||||
|
{
|
||||||
|
cookieSandbox,
|
||||||
|
successCodes: false
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
if (xmlhttp.status != 200 && xmlhttp.status != 204) {
|
if (xmlhttp.status != 200 && xmlhttp.status != 204) {
|
||||||
Zotero.debug("Attachment HEAD request returned with status code "
|
Zotero.debug("Attachment HEAD request returned with status code "
|
||||||
+ xmlhttp.status + " in Zotero.MIME.getMIMETypeFromURL()", 2);
|
+ xmlhttp.status + " in Zotero.MIME.getMIMETypeFromURL()", 2);
|
||||||
|
@ -356,7 +363,6 @@ Zotero.MIME = new function(){
|
||||||
var hasNativeHandler = Zotero.MIME.hasNativeHandler(mimeType, ext);
|
var hasNativeHandler = Zotero.MIME.hasNativeHandler(mimeType, ext);
|
||||||
|
|
||||||
return [mimeType, hasNativeHandler];
|
return [mimeType, hasNativeHandler];
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue