mirror of
https://github.com/Kong/insomnia
synced 2024-11-07 22:30:15 +00:00
A bunch of small fixes
This commit is contained in:
parent
d2749c5363
commit
ac5fc055db
@ -270,7 +270,7 @@ describe('actuallySend()', () => {
|
|||||||
const lines = requestBody.split(/\r\n/);
|
const lines = requestBody.split(/\r\n/);
|
||||||
expect(lines.length).toBe(11);
|
expect(lines.length).toBe(11);
|
||||||
expect(lines[0]).toMatch(/^----------------------------\d{24}/);
|
expect(lines[0]).toMatch(/^----------------------------\d{24}/);
|
||||||
expect(lines[1]).toBe('Content-Disposition: form-data; name="foo"');
|
expect(lines[1]).toBe('Content-Disposition: form-data; name="foo"; filename="testfile.txt"');
|
||||||
expect(lines[2]).toBe('Content-Type: text/plain');
|
expect(lines[2]).toBe('Content-Type: text/plain');
|
||||||
expect(lines[3]).toBe('');
|
expect(lines[3]).toBe('');
|
||||||
expect(lines[4]).toBe('Hello World!\n');
|
expect(lines[4]).toBe('Hello World!\n');
|
||||||
|
@ -46,7 +46,7 @@ export const CHANGELOG_URL = isDevelopment() ?
|
|||||||
'https://changelog.insomnia.rest/changelog.json';
|
'https://changelog.insomnia.rest/changelog.json';
|
||||||
export const CHANGELOG_PAGE = 'https://insomnia.rest/changelog/';
|
export const CHANGELOG_PAGE = 'https://insomnia.rest/changelog/';
|
||||||
export const STATUS_CODE_RENDER_FAILED = -333;
|
export const STATUS_CODE_RENDER_FAILED = -333;
|
||||||
export const LARGE_RESPONSE_MB = 10;
|
export const LARGE_RESPONSE_MB = 5;
|
||||||
export const MOD_SYM = isMac() ? '⌘' : 'ctrl+';
|
export const MOD_SYM = isMac() ? '⌘' : 'ctrl+';
|
||||||
export const SEGMENT_WRITE_KEY = isDevelopment() ?
|
export const SEGMENT_WRITE_KEY = isDevelopment() ?
|
||||||
'z7fwuyxxTragtISwExCNnoqUlWZbr4Sy' :
|
'z7fwuyxxTragtISwExCNnoqUlWZbr4Sy' :
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
import electron from 'electron';
|
import electron from 'electron';
|
||||||
import NeDB from 'nedb';
|
import NeDB from 'nedb';
|
||||||
|
import fs from 'fs';
|
||||||
import fsPath from 'path';
|
import fsPath from 'path';
|
||||||
import {DB_PERSIST_INTERVAL} from './constants';
|
import {DB_PERSIST_INTERVAL} from './constants';
|
||||||
import {generateId} from './misc';
|
import {generateId} from './misc';
|
||||||
import {getModel, initModel} from '../models';
|
import {getModel, initModel} from '../models';
|
||||||
import * as models from '../models/index';
|
import * as models from '../models/index';
|
||||||
|
import AlertModal from '../ui/components/modals/AlertModal';
|
||||||
|
import {showModal} from '../ui/components/modals/index';
|
||||||
|
|
||||||
export const CHANGE_INSERT = 'insert';
|
export const CHANGE_INSERT = 'insert';
|
||||||
export const CHANGE_UPDATE = 'update';
|
export const CHANGE_UPDATE = 'update';
|
||||||
@ -49,9 +52,26 @@ export async function init (types, config = {}, forceReset = false) {
|
|||||||
|
|
||||||
const filePath = getDBFilePath(modelType);
|
const filePath = getDBFilePath(modelType);
|
||||||
|
|
||||||
|
const MBs = fs.statSync(filePath).size / 1024 / 1024;
|
||||||
|
if (modelType === models.response.type && MBs > 256) {
|
||||||
|
// NOTE: Node.js can't have a string longer than 256MB. Since the response DB can reach
|
||||||
|
// sizes that big, let's not even load it if it's bigger than that. Just start over.
|
||||||
|
console.warn(`Response DB too big (${MBs}). Deleting...`);
|
||||||
|
fs.unlinkSync(filePath);
|
||||||
|
|
||||||
|
// Can't show alert until the app renders, so delay for a bit first
|
||||||
|
setTimeout(() => {
|
||||||
|
showModal(AlertModal, {
|
||||||
|
title: 'Response DB Too Large',
|
||||||
|
message: 'Your combined responses have exceeded 256MB and have been flushed. ' +
|
||||||
|
'NOTE: A better solution to this will be implemented in a future release.'
|
||||||
|
});
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
db[modelType] = new NeDB(Object.assign({
|
db[modelType] = new NeDB(Object.assign({
|
||||||
|
autoload: true,
|
||||||
filename: filePath,
|
filename: filePath,
|
||||||
autoload: true
|
|
||||||
}, config));
|
}, config));
|
||||||
|
|
||||||
db[modelType].persistence.setAutocompactionInterval(DB_PERSIST_INTERVAL);
|
db[modelType].persistence.setAutocompactionInterval(DB_PERSIST_INTERVAL);
|
||||||
|
@ -209,7 +209,7 @@ export function describeByteSize (bytes) {
|
|||||||
} else if (bytes < 1024 * 1024 * 2) {
|
} else if (bytes < 1024 * 1024 * 2) {
|
||||||
size = bytes / 1024;
|
size = bytes / 1024;
|
||||||
unit = 'KB';
|
unit = 'KB';
|
||||||
} else if (bytes < 1024 * 1024 * 2) {
|
} else if (bytes < 1024 * 1024 * 1024 * 2) {
|
||||||
size = bytes / 1024 / 1024;
|
size = bytes / 1024 / 1024;
|
||||||
unit = 'MB';
|
unit = 'MB';
|
||||||
} else {
|
} else {
|
||||||
|
@ -13,11 +13,14 @@ import {getRenderedRequest} from './render';
|
|||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as db from './database';
|
import * as db from './database';
|
||||||
|
|
||||||
// Defined fallback strategies for DNS lookup
|
// Defined fallback strategies for DNS lookup. By default, request uses Node's
|
||||||
|
// default dns.resolve which uses c-ares to do lookups. This doesn't work for
|
||||||
|
// some people, so we also fallback to IPv6 then IPv4 to force it to use
|
||||||
|
// getaddrinfo (OS lookup) instead of c-ares (external lookup).
|
||||||
const FAMILY_FALLBACKS = [
|
const FAMILY_FALLBACKS = [
|
||||||
|
null, // Use the request library default lookup
|
||||||
6, // IPv6
|
6, // IPv6
|
||||||
4, // IPv4
|
4, // IPv4
|
||||||
null // If those don't work, don't specify and let request do it's thing
|
|
||||||
];
|
];
|
||||||
|
|
||||||
let cancelRequestFunction = null;
|
let cancelRequestFunction = null;
|
||||||
@ -65,7 +68,7 @@ export function _buildRequestConfig (renderedRequest, patch = {}) {
|
|||||||
formData[param.name] = {
|
formData[param.name] = {
|
||||||
value: fs.readFileSync(param.fileName),
|
value: fs.readFileSync(param.fileName),
|
||||||
options: {
|
options: {
|
||||||
fileName: pathBasename(param.fileName),
|
filename: pathBasename(param.fileName),
|
||||||
contentType: mime.lookup(param.fileName) // Guess the mime-type
|
contentType: mime.lookup(param.fileName) // Guess the mime-type
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,6 +200,7 @@ export function _actuallySend (renderedRequest, workspace, settings, familyIndex
|
|||||||
|
|
||||||
// Failed to connect while prioritizing IPv6 address, fallback to IPv4
|
// Failed to connect while prioritizing IPv6 address, fallback to IPv4
|
||||||
const isNetworkRelatedError = (
|
const isNetworkRelatedError = (
|
||||||
|
err.code === 'EAI_AGAIN' || // No entry
|
||||||
err.code === 'ENOENT' || // No entry
|
err.code === 'ENOENT' || // No entry
|
||||||
err.code === 'ENODATA' || // DNS resolve failed
|
err.code === 'ENODATA' || // DNS resolve failed
|
||||||
err.code === 'ENOTFOUND' || // Could not resolve DNS
|
err.code === 'ENOTFOUND' || // Could not resolve DNS
|
||||||
@ -209,8 +213,9 @@ export function _actuallySend (renderedRequest, workspace, settings, familyIndex
|
|||||||
if (isNetworkRelatedError && nextFamilyIndex < FAMILY_FALLBACKS.length) {
|
if (isNetworkRelatedError && nextFamilyIndex < FAMILY_FALLBACKS.length) {
|
||||||
const family = FAMILY_FALLBACKS[nextFamilyIndex];
|
const family = FAMILY_FALLBACKS[nextFamilyIndex];
|
||||||
console.log(`-- Falling back to family ${family} --`);
|
console.log(`-- Falling back to family ${family} --`);
|
||||||
_actuallySend(renderedRequest, workspace, settings, nextFamilyIndex)
|
_actuallySend(
|
||||||
.then(resolve, reject);
|
renderedRequest, workspace, settings, nextFamilyIndex
|
||||||
|
).then(resolve, reject);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"name": "insomnia",
|
"name": "insomnia",
|
||||||
"version": "4.0.12",
|
"version": "4.0.13",
|
||||||
"productName": "Insomnia",
|
"productName": "Insomnia",
|
||||||
"longName": "Insomnia REST Client",
|
"longName": "Insomnia REST Client",
|
||||||
"description": "A simple and beautiful REST API client",
|
"description": "A simple and beautiful REST API client",
|
||||||
@ -15,7 +15,7 @@
|
|||||||
"electron-squirrel-startup": "^1.0.0",
|
"electron-squirrel-startup": "^1.0.0",
|
||||||
"hkdf": "0.0.2",
|
"hkdf": "0.0.2",
|
||||||
"httpsnippet": "git@github.com:getinsomnia/httpsnippet.git#a3a2c0a0167fa844bf92df52a1442fa1d68a9053",
|
"httpsnippet": "git@github.com:getinsomnia/httpsnippet.git#a3a2c0a0167fa844bf92df52a1442fa1d68a9053",
|
||||||
"insomnia-importers": "^1.2.8",
|
"insomnia-importers": "^1.3.0",
|
||||||
"json-lint": "^0.1.0",
|
"json-lint": "^0.1.0",
|
||||||
"jsonpath-plus": "^0.15.0",
|
"jsonpath-plus": "^0.15.0",
|
||||||
"mime-types": "^2.1.12",
|
"mime-types": "^2.1.12",
|
||||||
|
@ -37,11 +37,12 @@ class WorkspaceDropdown extends Component {
|
|||||||
workspace: this.props.activeWorkspace,
|
workspace: this.props.activeWorkspace,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
// _handleShowShareSettings = () => {
|
|
||||||
// showModal(WorkspaceShareSettingsModal, {
|
_handleShowShareSettings = () => {
|
||||||
// workspace: this.props.activeWorkspace,
|
showModal(WorkspaceShareSettingsModal, {
|
||||||
// });
|
workspace: this.props.activeWorkspace,
|
||||||
// };
|
});
|
||||||
|
};
|
||||||
|
|
||||||
_handleSwitchWorkspace = workspaceId => {
|
_handleSwitchWorkspace = workspaceId => {
|
||||||
this.props.handleSetActiveWorkspace(workspaceId);
|
this.props.handleSetActiveWorkspace(workspaceId);
|
||||||
@ -93,8 +94,9 @@ class WorkspaceDropdown extends Component {
|
|||||||
<i className="fa fa-wrench"/> Workspace Settings
|
<i className="fa fa-wrench"/> Workspace Settings
|
||||||
<DropdownHint char="⇧,"/>
|
<DropdownHint char="⇧,"/>
|
||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
|
|
||||||
{/*<DropdownItem onClick={this._handleShowShareSettings}>*/}
|
{/*<DropdownItem onClick={this._handleShowShareSettings}>*/}
|
||||||
{/*<i className="fa fa-user"/> Share <strong>{activeWorkspace.name}</strong>*/}
|
{/*<i className="fa fa-user"/> Share <strong>{activeWorkspace.name}</strong>*/}
|
||||||
{/*</DropdownItem>*/}
|
{/*</DropdownItem>*/}
|
||||||
|
|
||||||
<DropdownDivider>Switch Workspace</DropdownDivider>
|
<DropdownDivider>Switch Workspace</DropdownDivider>
|
||||||
|
@ -109,7 +109,7 @@
|
|||||||
overflow: visible !important;
|
overflow: visible !important;
|
||||||
height: 0;
|
height: 0;
|
||||||
margin: @padding-md @padding-md @padding-md @padding-md;
|
margin: @padding-md @padding-md @padding-md @padding-md;
|
||||||
min-width: @dropdown-min-width;
|
min-width: @dropdown-min-width - @padding-md * 2;
|
||||||
|
|
||||||
.dropdown__divider__label {
|
.dropdown__divider__label {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
@ -355,7 +355,6 @@
|
|||||||
height: @line-height-xs;
|
height: @line-height-xs;
|
||||||
border-top: 1px solid @hl-md;
|
border-top: 1px solid @hl-md;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow: hidden;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar__footer > button,
|
.sidebar__footer > button,
|
||||||
@ -365,7 +364,7 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
color: @hl;
|
color: @hl;
|
||||||
width: 100%;
|
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@
|
|||||||
"electron-squirrel-startup": "^1.0.0",
|
"electron-squirrel-startup": "^1.0.0",
|
||||||
"hkdf": "0.0.2",
|
"hkdf": "0.0.2",
|
||||||
"httpsnippet": "git@github.com:getinsomnia/httpsnippet.git#a3a2c0a0167fa844bf92df52a1442fa1d68a9053",
|
"httpsnippet": "git@github.com:getinsomnia/httpsnippet.git#a3a2c0a0167fa844bf92df52a1442fa1d68a9053",
|
||||||
"insomnia-importers": "^1.2.8",
|
"insomnia-importers": "^1.3.0",
|
||||||
"json-lint": "^0.1.0",
|
"json-lint": "^0.1.0",
|
||||||
"jsonpath-plus": "^0.15.0",
|
"jsonpath-plus": "^0.15.0",
|
||||||
"mime-types": "^2.1.12",
|
"mime-types": "^2.1.12",
|
||||||
|
Loading…
Reference in New Issue
Block a user