Skip to content

Commit

Permalink
Fix/filter out content length (#7341)
Browse files Browse the repository at this point in the history
* filter out

* comment
  • Loading branch information
jackkav authored Apr 30, 2024
1 parent fcc8bee commit 2cac8a2
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from 'react-router-dom';

import { getContentTypeName, getMimeTypeFromContentType } from '../../../common/constants';
import { ResponseHeader } from '../../../models/response';
import { invariant } from '../../../utils/invariant';
import { isInMockContentTypeList, useMockRoutePatcher } from '../../routes/mock-route';
import { RequestLoaderData } from '../../routes/request';
Expand Down Expand Up @@ -74,14 +75,15 @@ export const MockResponseExtractor = () => {
onComplete: async name => {
invariant(activeResponse, 'Active response must be defined');
const body = await fs.readFile(activeResponse.bodyPath);
// TODO: consider setting selected mock server here rather than redirecting
// auth mechanism is too sensitive to allow content length checks
const headersWithoutContentLength: ResponseHeader[] = activeResponse.headers.filter(h => h.name.toLowerCase() !== 'content-length');
fetcher.submit(
JSON.stringify({
name: name,
body: body.toString(),
mimeType,
statusCode: activeResponse.statusCode,
headers: activeResponse.headers,
headers: headersWithoutContentLength,
mockServerName: activeWorkspace.name,
}),
{
Expand Down Expand Up @@ -111,14 +113,16 @@ export const MockResponseExtractor = () => {
});
return;
};
// auth mechanism is too sensitive to allow content length checks
const headersWithoutContentLength: ResponseHeader[] = activeResponse.headers.filter(h => h.name.toLowerCase() !== 'content-length');
fetcher.submit(
JSON.stringify({
name: name,
parentId: selectedMockServer,
body: body.toString(),
mimeType,
statusCode: activeResponse.statusCode,
headers: activeResponse.headers,
headers: headersWithoutContentLength,
}),
{
encType: 'application/json',
Expand Down

0 comments on commit 2cac8a2

Please sign in to comment.