Skip to content

Commit

Permalink
fix(mitm): workaround invalid http response codes
Browse files Browse the repository at this point in the history
  • Loading branch information
blakebyrnes committed Apr 1, 2022
1 parent f7e2187 commit 9b1afaa
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions mitm/handlers/HttpRequestHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,18 @@ export default class HttpRequestHandler extends BaseHttpHandler {
const context = this.context;
const { serverToProxyResponse, proxyToClientResponse, requestSession, events } = context;

// NOTE: nodejs won't allow an invalid status, but chrome will.
// TODO: we should find a way to keep this value
if (context.status > 599) {
log.info(`MitmHttpRequest.modifyStatusResponseCode`, {
sessionId: requestSession.sessionId,
request: `${context.method}: ${context.url.href}`,
actualStatus: context.status,
responseStatus: 599,
});
context.status = 599;
}

proxyToClientResponse.statusCode = context.status;
// write individually so we properly write header-lists
for (const [key, value] of Object.entries(context.responseHeaders)) {
Expand Down

0 comments on commit 9b1afaa

Please sign in to comment.