Skip to content

Commit

Permalink
add headers when body is changed (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
sirdarckcat authored Jan 9, 2021
1 parent 6d15158 commit b63e5a2
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 b63e5a2

Please sign in to comment.