Adds support for 303, 307 and 308 http status codes.
This commit is contained in:
parent
5a6e557913
commit
450232e7b7
1 changed files with 7 additions and 10 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { client } from "./sni.js";
|
||||
import { findTxtRecord, isHostBlacklisted, combineURLs } from "./util.js";
|
||||
import {client} from "./sni.js";
|
||||
import {findTxtRecord, isHostBlacklisted, combineURLs} from "./util.js";
|
||||
|
||||
/**
|
||||
* @typedef {Object} Cache
|
||||
|
|
@ -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();
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
editor.link_modal.header
Reference in a new issue