From 51349a5a97aa8427cb4d6db535cc947e0f1ced02 Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Tue, 28 Jan 2025 10:45:08 -0500 Subject: [PATCH] Local API: Read headers case-insensitively --- chrome/content/zotero/xpcom/localAPI/server_localAPI.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/xpcom/localAPI/server_localAPI.js b/chrome/content/zotero/xpcom/localAPI/server_localAPI.js index 070a29b7d8..731fba8650 100644 --- a/chrome/content/zotero/xpcom/localAPI/server_localAPI.js +++ b/chrome/content/zotero/xpcom/localAPI/server_localAPI.js @@ -91,8 +91,10 @@ class LocalAPIEndpoint { return this.makeResponse(403, 'text/plain', 'Local API is not enabled'); } + requestData.headers = new Headers(requestData.headers); + let apiVersion = parseInt( - requestData.headers['Zotero-API-Version'] + requestData.headers.get('Zotero-API-Version') || requestData.searchParams.get('v') || LOCAL_API_VERSION ); @@ -217,7 +219,7 @@ class LocalAPIEndpoint { if (lastModifiedVersion !== undefined) { headers['Last-Modified-Version'] = lastModifiedVersion; } - let ifModifiedSinceVersion = requestData.headers['If-Modified-Since-Version']; + let ifModifiedSinceVersion = requestData.headers.get('If-Modified-Since-Version'); if (ifModifiedSinceVersion) { ifModifiedSinceVersion = parseInt(ifModifiedSinceVersion); if (ifModifiedSinceVersion !== 0 && lastModifiedVersion <= ifModifiedSinceVersion) { @@ -244,7 +246,7 @@ class LocalAPIEndpoint { let links = {}; let buildURL = (searchParams) => { - let url = new URL(requestData.pathname, 'http://' + requestData.headers['Host']); + let url = new URL(requestData.pathname, 'http://' + requestData.headers.get('Host')); url.search = searchParams.toString(); return url.toString(); };