diff --git a/lib/bimi-handler.js b/lib/bimi-handler.js index 5b229b2b..b40a3ecc 100644 --- a/lib/bimi-handler.js +++ b/lib/bimi-handler.js @@ -77,6 +77,13 @@ class BimiHandler { dispatcher: fetchAgent }); + if (res.status === 304) { + // no changes + let err = new Error('No changes'); + err.code = 'NO_CHANGES'; + throw err; + } + if (!res.ok) { let error = new Error(`Request failed with status ${res.status}`); error.code = 'HTTP_REQUEST_FAILED'; @@ -106,20 +113,13 @@ class BimiHandler { _bimi_url: url, _bimi_type: bimiType, _bimi_domain: bimiDomain, - _status_code: res?.status, + _status_code: res.status, _req_etag: bimiDocument.etag, _req_last_modified: bimiDocument.lastModified, - _res_etag: res?.headers?.get('ETag'), - _res_last_modified: res?.headers?.get('Last-Modified') + _res_etag: res.headers.get('ETag'), + _res_last_modified: res.headers.get('Last-Modified') }); - if (res?.status === 304) { - // no changes - let err = new Error('No changes'); - err.code = 'NO_CHANGES'; - throw err; - } - if (!res.status || res.status < 200 || res.status >= 300) { let err = new Error(`Invalid response code ${res.status || '-'}`);