浏览代码

feat: add HEAD method in the HTTP Request block(#1591)

Ahmad Kholid 1 年之前
父节点
当前提交
81a92a5661

+ 2 - 2
src/components/newtab/workflow/edit/EditWebhook.vue

@@ -173,8 +173,8 @@ const emit = defineEmits(['update:data']);
 
 const { t } = useI18n();
 
-const methods = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'];
-const notHaveBody = ['GET'];
+const methods = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD'];
+const notHaveBody = ['GET', 'HEAD'];
 const copyHeaders = JSON.parse(JSON.stringify(props.data.headers));
 
 const activeTab = ref('headers');

+ 7 - 11
src/workflowEngine/blocksHandler/handlerWebhook.js

@@ -3,16 +3,6 @@ import { isWhitespace } from '@/utils/helper';
 import { executeWebhook } from '../utils/webhookUtil';
 import renderString from '../templating/renderString';
 
-function fileReader(blob) {
-  return new Promise((resolve) => {
-    const reader = new FileReader();
-    reader.onload = () => {
-      resolve(reader.result);
-    };
-    reader.readAsDataURL(blob);
-  });
-}
-
 const ALL_HTTP_RESPONSE_KEYWORD = '$response';
 
 export async function webhook({ data, id }, { refData }) {
@@ -83,7 +73,13 @@ export async function webhook({ data, id }, { refData }) {
       }
     } else if (data.responseType === 'base64') {
       const blob = await response.blob();
-      const base64 = await fileReader(blob);
+      const base64 = await new Promise((resolve) => {
+        const reader = new FileReader();
+        reader.onload = () => {
+          resolve(reader.result);
+        };
+        reader.readAsDataURL(blob);
+      });
 
       returnData = base64;
     } else {

+ 1 - 1
src/workflowEngine/utils/webhookUtil.js

@@ -79,7 +79,7 @@ const contentTypes = {
   'form-data': 'multipart/form-data',
   form: 'application/x-www-form-urlencoded',
 };
-const notHaveBody = ['GET', 'DELETE'];
+const notHaveBody = ['GET', 'HEAD'];
 
 export async function executeWebhook({
   url,