Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: add response content type #6649

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/insomnia/src/main/network/curl.ts
Expand Up @@ -222,6 +222,7 @@ const openCurlConnection = async (
settingSendCookies: request.settingSendCookies,
settingStoreCookies: request.settingStoreCookies,
bodyCompression: null,
contentType: CurlConnections.get(options.requestId)?.getInfo(Curl.info.CONTENT_TYPE) as string || '',
};
const settings = await models.settings.get();
const res = await models.response.create(responsePatch, settings.maxHistoryResponses);
Expand Down
1 change: 1 addition & 0 deletions packages/insomnia/src/main/network/libcurl-promise.ts
Expand Up @@ -205,6 +205,7 @@ export const curlRequest = (options: CurlRequestOptions) => new Promise<CurlRequ
bytesRead: curl.getInfo(Curl.info.SIZE_DOWNLOAD) as number,
elapsedTime: curl.getInfo(Curl.info.TOTAL_TIME) as number * 1000,
url: curl.getInfo(Curl.info.EFFECTIVE_URL) as string,
contentType: curl.getInfo(Curl.info.CONTENT_TYPE) as string,
};
curl.close();
await waitForStreamToFinish(responseBodyWriteStream);
Expand Down
2 changes: 2 additions & 0 deletions packages/insomnia/src/main/network/websocket.ts
Expand Up @@ -297,6 +297,8 @@ const openWebSocketConnection = async (
eventLogPath: responseBodyPath,
settingSendCookies: request.settingSendCookies,
settingStoreCookies: request.settingStoreCookies,
// TODO: decide if this is the right thing to do, ws doesn't have a content type
contentType: 'text/event-stream',
};
const settings = await models.settings.get();
const res = await models.webSocketResponse.create(responsePatch, settings.maxHistoryResponses);
Expand Down
Expand Up @@ -16,6 +16,7 @@ import { ResponseHistoryDropdown } from '../dropdowns/response-history-dropdown'
import { ErrorBoundary } from '../error-boundary';
import { Pane, PaneHeader as OriginalPaneHeader } from '../panes/pane';
import { PlaceholderResponsePane } from '../panes/placeholder-response-pane';
import { ResponsePane } from '../panes/response-pane';
import { SvgIcon } from '../svg-icon';
import { SizeTag } from '../tags/size-tag';
import { StatusTag } from '../tags/status-tag';
Expand Down Expand Up @@ -95,6 +96,9 @@ export const RealtimeResponsePane: FC<{ requestId: string }> = () => {
</Pane>
);
}
if (activeResponse.contentType !== 'text/event-stream') {
return <ResponsePane runningRequests={{}} />;
}
return <RealtimeActiveResponsePane response={activeResponse} />;
};

Expand Down