fix: 修復未自動添加Headers

This commit is contained in:
2025-01-27 16:48:15 +08:00
parent 8b20764404
commit b26d0abc93
2 changed files with 7 additions and 6 deletions

View File

@@ -16,6 +16,7 @@ fs.watch(path, async function (event, filename) {
if (!['GET', 'POST', 'PUT', 'PATCH', 'HEAD', 'DELETE', 'OPTIONS', 'TRACE'].includes(method)) {
return
}
requestData.Response = {Headers: {}}
try {
const res = await got({
url: requestData.Request.URL,
@@ -26,7 +27,7 @@ fs.watch(path, async function (event, filename) {
requestData.Response.StatusCode = res.statusCode
Object.keys(res.headers).forEach((e) => {
requestData.Response.Headers[e] = res.headers[e]
if (requestData.Response) requestData.Response.Headers[e] = res.headers[e]
})
requestData.Response.Body = res.body
} catch (error) {

View File

@@ -2,13 +2,13 @@ export interface IrequestData {
Request: {
Mode: string
URL: string
Headers: any
Body: string
Headers?: any
Body?: string
}
Response: {
StatusCode: number
Response?: {
StatusCode?: number
Headers: any
Body: string
Body?: string
}
Processed?: boolean
}