From b63e5a2749bd4c9937ac74e5246b4012f9c2fcf1 Mon Sep 17 00:00:00 2001 From: "Eduardo' Vela\" Nava (sirdarckcat)" Date: Sat, 9 Jan 2021 14:12:22 +0100 Subject: [PATCH] add headers when body is changed (#188) --- v2/background/src/request.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/v2/background/src/request.ts b/v2/background/src/request.ts index cf83f8a..f17f2a0 100644 --- a/v2/background/src/request.ts +++ b/v2/background/src/request.ts @@ -69,13 +69,13 @@ export abstract class Intercepted implements InterceptedData { if (obj.url && obj.url != this.url) { modified.url = obj.url; } - if (obj.requestHeaders && JSON.stringify(obj.requestHeaders) != JSON.stringify(this.requestHeaders)) { - modified.headers = obj.requestHeaders.reduce((ret, header) => - Object.assign({ [header.name]: header.value }, ret), {}); - } if (obj.requestBody && obj.requestBody != this.requestBody) { modified.postData = obj.requestBody; } + if (obj.requestHeaders && (JSON.stringify(obj.requestHeaders) != JSON.stringify(this.requestHeaders) || modified.postData)) { + modified.headers = obj.requestHeaders.reduce((ret, header) => + Object.assign({ [header.name]: header.value }, ret), {}); + } return modified; }