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

feat: configure response threshold #6520

Open
wants to merge 20 commits into
base: develop
Choose a base branch
from
Open
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: 0 additions & 1 deletion packages/insomnia/src/common/constants.ts
Expand Up @@ -67,7 +67,6 @@ export const REQUEST_TIME_TO_SHOW_COUNTER = 1; // Seconds
*/
export const REQUEST_SETUP_TEARDOWN_COMPENSATION = 200;
export const STATUS_CODE_PLUGIN_ERROR = -222;
export const LARGE_RESPONSE_MB = 5;
export const HUGE_RESPONSE_MB = 100;
export const FLEXIBLE_URL_REGEX = /^(http|https):\/\/[\wàâäèéêëîïôóœùûüÿçÀÂÄÈÉÊËÎÏÔŒÙÛÜŸÇ\-_.]+[/\wàâäèéêëîïôóœùûüÿçÀÂÄÈÉÊËÎÏÔŒÙÛÜŸÇ.\-+=:\][@%^*&!#?;$~'(),]*/;
export const CHECK_FOR_UPDATES_INTERVAL = 1000 * 60 * 60 * 24;
Expand Down
1 change: 1 addition & 0 deletions packages/insomnia/src/common/settings.ts
Expand Up @@ -128,6 +128,7 @@ export interface Settings {
maxHistoryResponses: number;
maxRedirects: number;
maxTimelineDataSizeKB: number;
maxResponseSizeKB: number;
noProxy: string;
nunjucksPowerUserMode: boolean;
pluginConfig: PluginConfigMap;
Expand Down
1 change: 1 addition & 0 deletions packages/insomnia/src/models/settings.ts
Expand Up @@ -53,6 +53,7 @@ export function init(): BaseSettings {
maxHistoryResponses: 20,
maxRedirects: 10,
maxTimelineDataSizeKB: 10,
maxResponseSizeKB: 5_000,
noProxy: '',
nunjucksPowerUserMode: false,
pluginConfig: {},
Expand Down
Expand Up @@ -163,6 +163,7 @@ export const ResponsePane: FC<Props> = ({
<ResponseViewer
key={activeResponse._id}
bytes={Math.max(activeResponse.bytesContent, activeResponse.bytesRead)}
maxResponseSizeKB={settings.maxResponseSizeKB}
contentType={activeResponse.contentType || ''}
disableHtmlPreviewJs={settings.disableHtmlPreviewJs}
disablePreviewLinks={settings.disableResponsePreviewLinks}
Expand Down
6 changes: 6 additions & 0 deletions packages/insomnia/src/ui/components/settings/general.tsx
Expand Up @@ -252,6 +252,12 @@ export const General: FC = () => {
help="Enter the maximum size in kibibytes to show on the response timeline. Decrease the number for less detailed responses."
min={0}
/>
<NumberSetting
label="Response threshold size (KB)"
setting='maxResponseSizeKB'
help="Enter the maximum size in kilobytes to show on the response. Enter 0 to disable thresholding."
min={0}
/>
</div>

<hr className="pad-top" />
Expand Down
Expand Up @@ -7,7 +7,6 @@ import React, {

import {
HUGE_RESPONSE_MB,
LARGE_RESPONSE_MB,
PREVIEW_MODE_FRIENDLY,
PREVIEW_MODE_RAW,
} from '../../../common/constants';
Expand Down Expand Up @@ -38,6 +37,7 @@ export function xmlDecode(input: string) {
}
export interface ResponseViewerProps {
bytes: number;
maxResponseSizeKB: number;
contentType: string;
disableHtmlPreviewJs: boolean;
disablePreviewLinks: boolean;
Expand All @@ -55,6 +55,7 @@ export interface ResponseViewerProps {

export const ResponseViewer = ({
bytes,
maxResponseSizeKB,
getBody,
contentType: originalContentType,
disableHtmlPreviewJs,
Expand All @@ -69,7 +70,7 @@ export const ResponseViewer = ({
updateFilter,
url,
}: ResponseViewerProps) => {
const largeResponse = bytes > LARGE_RESPONSE_MB * 1024 * 1024;
const largeResponse = maxResponseSizeKB > 0 ? bytes > maxResponseSizeKB * 1024 : false;
const hugeResponse = bytes > HUGE_RESPONSE_MB * 1024 * 1024;
const [blockingBecauseTooLarge, setBlockingBecauseTooLarge] = useState(!alwaysShowLargeResponses && largeResponse);
const [parseError, setParseError] = useState('');
Expand Down Expand Up @@ -191,7 +192,7 @@ export const ResponseViewer = ({
) : (
<Fragment>
<p className="pad faint">
Response over {LARGE_RESPONSE_MB}MB hidden for performance reasons
Response over {maxResponseSizeKB}KB hidden for performance reasons
</p>
<div>
<button
Expand Down