diff --git a/CHANGELOG b/CHANGELOG index 1ff4fdf92..2f20cb78c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ Unreleased: mitmproxy next * Fix links to anticache docs in mitmweb and use HTTPS for links to documentation (@rugk) * Updated typing for WebsocketMessage.content (@prinzhorn) * Prevent transparent mode from connecting to itself in the basic cases (@prinzhorn) + * Display HTTP trailers in mitmweb (@sanlengjingvv) * --- TODO: add new PRs above this line --- diff --git a/mitmproxy/tools/web/app.py b/mitmproxy/tools/web/app.py index 9671a497e..53bf7f6e2 100644 --- a/mitmproxy/tools/web/app.py +++ b/mitmproxy/tools/web/app.py @@ -305,6 +305,10 @@ class FlowHandler(RequestHandler): request.headers.clear() for header in v: request.headers.add(*header) + elif k == "trailers": + request.trailers.clear() + for trailer in v: + request.trailers.add(*trailer) elif k == "content": request.text = v else: @@ -321,6 +325,10 @@ class FlowHandler(RequestHandler): response.headers.clear() for header in v: response.headers.add(*header) + elif k == "trailers": + response.trailers.clear() + for trailer in v: + response.trailers.add(*trailer) elif k == "content": response.text = v else: diff --git a/web/src/js/__tests__/components/FlowView/MessagesSpec.js b/web/src/js/__tests__/components/FlowView/MessagesSpec.js index 02db77e8f..c972a2e06 100644 --- a/web/src/js/__tests__/components/FlowView/MessagesSpec.js +++ b/web/src/js/__tests__/components/FlowView/MessagesSpec.js @@ -58,7 +58,7 @@ describe('Request Component', () => { }) it('should handle change on flow request header', () => { - let headers = TestUtils.findRenderedComponentWithType(provider, Headers) + let headers = TestUtils.scryRenderedComponentsWithType(provider, Headers).filter(headers => headers.props.type === 'headers')[0] headers.props.onChange('foo') expect(store.getActions()).toEqual([updateEdit({ request: { headers: 'foo' }})]) }) @@ -115,7 +115,7 @@ describe('Response Component', () => { }) it('should handle change on flow response headers', () => { - let headers = TestUtils.findRenderedComponentWithType(provider, Headers) + let headers = TestUtils.scryRenderedComponentsWithType(provider, Headers).filter(headers => headers.props.type === 'headers')[0] headers.props.onChange('foo') expect(store.getActions()).toEqual([updateEdit( { response: { headers: 'foo' }})]) }) diff --git a/web/src/js/__tests__/components/FlowView/__snapshots__/MessagesSpec.js.snap b/web/src/js/__tests__/components/FlowView/__snapshots__/MessagesSpec.js.snap index cc021f131..387f868ab 100644 --- a/web/src/js/__tests__/components/FlowView/__snapshots__/MessagesSpec.js.snap +++ b/web/src/js/__tests__/components/FlowView/__snapshots__/MessagesSpec.js.snap @@ -199,6 +199,111 @@ exports[`Request Component should render correctly 1`] = `
+ + + : + + | ++ + | +
+ + + : + + | ++ + | +