Adds support for 303, 307 and 308 http status codes.

This commit is contained in:
Pierre Lannoy 2023-12-12 20:03:48 +01:00
commit 450232e7b7
Signed by: Pierre Lannoy
GPG key ID: D27231EF87D53F31

View file

@ -33,8 +33,8 @@ async function buildCache(host) {
url = url.slice(0, -1);
expand = true;
}
if(!['301', '302'].includes(httpStatus)) {
throw new Error(`The record "${url}" wants to use the http status code ${httpStatus} which is not allowed (only 301 and 302)`);
if (!['301', '302', '303', '307', '308'].includes(httpStatus)) {
throw new Error(`The record "${url}" wants to use the ${httpStatus} http status code which is forbidden. Only 301, 302, 303, 307 and 308 http status code are allowed`);
}
return {
url,
@ -60,8 +60,7 @@ const listener = async function (req, res) {
'content-type': 'application/octet-stream'
});
res.write(client.challengeCallbacks());
}
else {
} else {
res.writeHead(404);
}
return;
@ -87,12 +86,10 @@ const listener = async function (req, res) {
'Location': cache.expand ? combineURLs(cache.url, url) : cache.url,
});
return;
}
catch (error) {
} catch (error) {
res.writeHead(400);
res.write(error.message || 'Unknown error');
}
finally {
} finally {
res.end();
}
};