feat: support HEAD method

This commit is contained in:
onejibang 2024-05-13 19:12:22 +08:00
parent 26e83798da
commit 93a1ba7b50

View File

@ -376,12 +376,17 @@ export function HTTP(defaultOptions = { baseURL: '' }) {
worker = new Promise(async (resolve, reject) => { worker = new Promise(async (resolve, reject) => {
const requestHandler = { const requestHandler = {
get: $Plugins.HttpGet, get: $Plugins.HttpGet,
head: $Plugins.HttpHead,
post: $Plugins.HttpPost, post: $Plugins.HttpPost,
put: $Plugins.HttpPut, put: $Plugins.HttpPut,
delete: $Plugins.HttpDelete, delete: $Plugins.HttpDelete,
}; };
const request = requestHandler[method.toLowerCase()]; const request = requestHandler[method.toLowerCase()];
if (!request) reject('GUI.for.Cores未实现当前方法' + method); if (!request)
reject(
'[GUI.for.Cores] This method is not implemented: ' +
method,
);
try { try {
const { url, headers } = options; const { url, headers } = options;
const response = await request(url, headers, options.body); const response = await request(url, headers, options.body);