Skip to content

Commit

Permalink
Add request headers when body is modified (#189)
Browse files Browse the repository at this point in the history
* add missing request body (#186)

* add headers when body is changed
  • Loading branch information
sirdarckcat authored Jan 9, 2021
1 parent 18d719e commit 1ad8700
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions v2/background/src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 1ad8700

Please sign in to comment.