Skip to content

Commit

Permalink
fix: fixed response headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Raymond Ottun committed Oct 24, 2021
1 parent 9693df7 commit d4bd313
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
6 changes: 5 additions & 1 deletion src/server/routes/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ interface Props {
engine: Engine;
}

const FILTERED_HEADERS = ['transfer-encoding', 'connection'];

export const createMocksRouter = ({ engine }: Props): Router => {
const router = Router();

Expand All @@ -27,7 +29,9 @@ export const createMocksRouter = ({ engine }: Props): Router => {

const record = await engine.execute(engineRequest);
Object.entries(record.response.headers || {}).forEach(([key, value]) => {
res.setHeader(key, value as string);
if (!FILTERED_HEADERS.includes(key.toLocaleLowerCase())) {
res.setHeader(key, value as string);
}
});

res.locals = { body: record.response.body || {}, code: record.response.statusCode || 200 };
Expand Down
24 changes: 8 additions & 16 deletions ui/src/components/records/RequestPath.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
import { Space, Typography } from 'antd';
import { SelectOutlined } from '@ant-design/icons';
import { Record } from '../../../../src/engine';

export const RequestPath = ({ record }: { record: Record }) => {
const { matches = [] } = record;
const [matched] = matches;
if (matched) {
return (
<Space>
{/* @ts-ignore: ellipsis ignore */}
<Typography.Text ellipsis={record.request.path.slice(5)} underline>
{record.request.path}
</Typography.Text>
<SelectOutlined />
</Space>
);
}
const { proxyRequest, request } = record;
const path = proxyRequest ? proxyRequest.url : request.path;
const normalizedPath = path.replace(/:443|80/, '');

// @ts-ignore: ellipsis ignore
return <Typography.Text ellipsis={record.request.path.slice(5)}>{record.request.path}</Typography.Text>;
return (
<Space>
<Typography.Text>{normalizedPath}</Typography.Text>
</Space>
);
};

0 comments on commit d4bd313

Please sign in to comment.