mirror of
https://github.com/Kong/insomnia
synced 2024-11-07 22:30:15 +00:00
Slower response refresh
This commit is contained in:
parent
8f00d81a7d
commit
852a6e6f14
@ -60,12 +60,10 @@ export function _actuallySend (
|
||||
workspace: Workspace,
|
||||
settings: Settings
|
||||
): Promise<{bodyBuffer: ?Buffer, response: ResponsePatch}> {
|
||||
console.log('[curl] CREATING PROMISE');
|
||||
return new Promise(async resolve => {
|
||||
let timeline: Array<ResponseTimelineEntry> = [];
|
||||
|
||||
// Initialize the curl handle
|
||||
console.log('[curl] INIT CURL HANDLE');
|
||||
const curl = new Curl();
|
||||
|
||||
/** Helper function to respond with a success */
|
||||
@ -132,7 +130,6 @@ export function _actuallySend (
|
||||
curl.close();
|
||||
};
|
||||
|
||||
console.log('[curl] SETTING BASIC OPTS');
|
||||
// Set all the basic options
|
||||
setOpt(Curl.option.FOLLOWLOCATION, settings.followRedirects);
|
||||
setOpt(Curl.option.MAXREDIRS, 20);
|
||||
@ -158,7 +155,6 @@ export function _actuallySend (
|
||||
break;
|
||||
}
|
||||
|
||||
console.log('[curl] SETTING DEBUG FUNC');
|
||||
// Setup debug handler
|
||||
setOpt(Curl.option.DEBUGFUNCTION, (infoType: string, content: string) => {
|
||||
const name = Object.keys(Curl.info.debug).find(k => Curl.info.debug[k] === infoType) || '';
|
||||
@ -170,8 +166,6 @@ export function _actuallySend (
|
||||
return 0;
|
||||
}
|
||||
|
||||
console.log('[curl] TIMELINE PUSH', {name, content});
|
||||
|
||||
// Ignore the possibly large data messages
|
||||
if (infoType === Curl.info.debug.DATA_OUT) {
|
||||
if (content.length === 0) {
|
||||
@ -221,7 +215,6 @@ export function _actuallySend (
|
||||
return 0;
|
||||
}, true);
|
||||
|
||||
console.log('[curl] BUILD URL');
|
||||
// Set the URL, including the query parameters
|
||||
const qs = querystring.buildFromParams(renderedRequest.parameters);
|
||||
const url = querystring.joinUrl(renderedRequest.url, qs);
|
||||
@ -276,7 +269,6 @@ export function _actuallySend (
|
||||
|
||||
// Set cookies from jar
|
||||
if (renderedRequest.settingSendCookies) {
|
||||
console.log('[curl] SETUP COOKIES');
|
||||
// Tell Curl to store cookies that it receives. This is only important if we receive
|
||||
// a cookie on a redirect that needs to be sent on the next request in the chain.
|
||||
curl.setOpt(Curl.option.COOKIEFILE, '');
|
||||
@ -318,7 +310,6 @@ export function _actuallySend (
|
||||
|
||||
// Set proxy settings if we have them
|
||||
if (settings.proxyEnabled) {
|
||||
console.log('[curl] SETUP PROXY');
|
||||
const {protocol} = urlParse(renderedRequest.url);
|
||||
const {httpProxy, httpsProxy, noProxy} = settings;
|
||||
const proxyHost = protocol === 'https:' ? httpsProxy : httpProxy;
|
||||
@ -337,7 +328,6 @@ export function _actuallySend (
|
||||
|
||||
// Set client certs if needed
|
||||
for (const certificate of workspace.certificates) {
|
||||
console.log('[curl] SETUP CERTS');
|
||||
if (certificate.disabled) {
|
||||
continue;
|
||||
}
|
||||
@ -392,7 +382,6 @@ export function _actuallySend (
|
||||
let noBody = false;
|
||||
let requestBody = null;
|
||||
const expectsBody = ['POST', 'PUT', 'PATCH'].includes(renderedRequest.method.toUpperCase());
|
||||
console.log('[curl] SETUP BODY');
|
||||
if (renderedRequest.body.mimeType === CONTENT_TYPE_FORM_URLENCODED) {
|
||||
requestBody = querystring.buildFromParams(renderedRequest.body.params || [], false);
|
||||
} else if (renderedRequest.body.mimeType === CONTENT_TYPE_FORM_DATA) {
|
||||
@ -443,14 +432,12 @@ export function _actuallySend (
|
||||
const dataBuffers = [];
|
||||
let dataBuffersLength = 0;
|
||||
curl.on('data', chunk => {
|
||||
console.log('[curl] GOT DATA', chunk + '');
|
||||
dataBuffers.push(chunk);
|
||||
dataBuffersLength += chunk.length;
|
||||
});
|
||||
|
||||
// Handle Authorization header
|
||||
if (!hasAuthHeader(headers) && !renderedRequest.authentication.disabled) {
|
||||
console.log('[curl] AUTH HEADERS');
|
||||
if (renderedRequest.authentication.type === AUTH_BASIC) {
|
||||
const {username, password} = renderedRequest.authentication;
|
||||
setOpt(Curl.option.HTTPAUTH, Curl.auth.BASIC);
|
||||
@ -513,7 +500,6 @@ export function _actuallySend (
|
||||
|
||||
// Handle the response ending
|
||||
curl.on('end', async function (_1, _2, allCurlHeadersObjects) {
|
||||
console.log('[curl] REQUEST END', allCurlHeadersObjects);
|
||||
// Headers are an array (one for each redirect)
|
||||
const lastCurlHeadersObject = allCurlHeadersObjects[allCurlHeadersObjects.length - 1];
|
||||
|
||||
|
@ -7,23 +7,5 @@
|
||||
"description": "Debug APIs like a human, not a robot",
|
||||
"homepage": "https://insomnia.rest",
|
||||
"author": "Insomnia <support@insomnia.rest>",
|
||||
"main": "main.min.js",
|
||||
"dependencies": {
|
||||
"electron-context-menu": "^0.9.0",
|
||||
"electron-devtools-installer": "^2.2.0",
|
||||
"electron-squirrel-startup": "^1.0.0",
|
||||
"deep-equal": "^1.0.1",
|
||||
"hkdf": "^0.0.2",
|
||||
"httpsnippet": "git://github.com/getinsomnia/httpsnippet.git#85e00f4d2574ff2457f3de21dd3faf50db4ab74a",
|
||||
"insomnia-importers": "^1.3.9",
|
||||
"jsonpath": "^0.2.11",
|
||||
"mkdirp": "^0.5.1",
|
||||
"nedb": "^1.8.0",
|
||||
"node-forge": "^0.7.0",
|
||||
"node-libcurl": "git://github.com/getinsomnia/node-libcurl.git#d3ee4d436a174c2bd5f2dc89b165257a5cac32ea",
|
||||
"srp-js": "^0.2.0",
|
||||
"tar": "^3.1.7",
|
||||
"tough-cookie": "^2.3.1",
|
||||
"vkbeautify": "^0.99.1"
|
||||
}
|
||||
"main": "main.min.js"
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
import React, {PureComponent} from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import autobind from 'autobind-decorator';
|
||||
import classnames from 'classnames';
|
||||
import {REQUEST_TIME_TO_SHOW_COUNTER} from '../../common/constants';
|
||||
|
||||
@autobind
|
||||
class ResponseTimer extends PureComponent {
|
||||
constructor (props) {
|
||||
super(props);
|
||||
@ -16,8 +18,15 @@ class ResponseTimer extends PureComponent {
|
||||
clearInterval(this._interval);
|
||||
}
|
||||
|
||||
componentWillReceiveProps (nextProps) {
|
||||
const {loadStartTime} = nextProps;
|
||||
_handleUpdateElapsedTime () {
|
||||
const {loadStartTime} = this.props;
|
||||
const millis = Date.now() - loadStartTime - 200;
|
||||
const elapsedTime = Math.round(millis / 1000);
|
||||
this.setState({elapsedTime});
|
||||
}
|
||||
|
||||
componentDidUpdate () {
|
||||
const {loadStartTime} = this.props;
|
||||
|
||||
if (loadStartTime <= 0) {
|
||||
clearInterval(this._interval);
|
||||
@ -25,11 +34,8 @@ class ResponseTimer extends PureComponent {
|
||||
}
|
||||
|
||||
clearInterval(this._interval); // Just to be sure
|
||||
this._interval = setInterval(() => {
|
||||
const millis = Date.now() - loadStartTime - 200;
|
||||
const elapsedTime = Math.round(millis / 100) / 10;
|
||||
this.setState({elapsedTime});
|
||||
}, 100);
|
||||
this._interval = setInterval(this._handleUpdateElapsedTime, 1000);
|
||||
this._handleUpdateElapsedTime();
|
||||
}
|
||||
|
||||
render () {
|
||||
@ -40,8 +46,8 @@ class ResponseTimer extends PureComponent {
|
||||
|
||||
return (
|
||||
<div className={classnames('overlay theme--overlay', {'overlay--hidden': !show})}>
|
||||
{elapsedTime > REQUEST_TIME_TO_SHOW_COUNTER
|
||||
? <h2>{elapsedTime.toFixed(1)} seconds...</h2>
|
||||
{elapsedTime >= REQUEST_TIME_TO_SHOW_COUNTER
|
||||
? <h2>{elapsedTime} second{elapsedTime === 1 ? '' : 's'}...</h2>
|
||||
: <h2>Loading...</h2>
|
||||
}
|
||||
<div className="pad">
|
||||
|
6
package-lock.json
generated
6
package-lock.json
generated
@ -10067,9 +10067,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"reselect": {
|
||||
"version": "2.5.4",
|
||||
"resolved": "https://registry.npmjs.org/reselect/-/reselect-2.5.4.tgz",
|
||||
"integrity": "sha1-t9I/3wC4P6etAnlUb427vXZccEc="
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/reselect/-/reselect-3.0.1.tgz",
|
||||
"integrity": "sha1-79qpjqdFEyTQkrKyFjpqHXqaIUc="
|
||||
},
|
||||
"resolve": {
|
||||
"version": "1.3.3",
|
||||
|
22
package.json
22
package.json
@ -146,7 +146,7 @@
|
||||
"react-tabs": "^1.1.0",
|
||||
"redux": "^3.7.2",
|
||||
"redux-thunk": "^2.2.0",
|
||||
"reselect": "^2.5.4",
|
||||
"reselect": "^3.0.1",
|
||||
"simple-react-pdf": "^1.0.8",
|
||||
"srp-js": "^0.2.0",
|
||||
"tar": "^3.1.7",
|
||||
@ -203,5 +203,23 @@
|
||||
"webpack-dev-server": "^2.4.1",
|
||||
"webpack-hot-middleware": "^2.17.1",
|
||||
"webpack-target-electron-renderer": "^0.4.0"
|
||||
}
|
||||
},
|
||||
"externals": [
|
||||
"electron-context-menu",
|
||||
"electron-devtools-installer",
|
||||
"electron-squirrel-startup",
|
||||
"deep-equal",
|
||||
"hkdf",
|
||||
"httpsnippet",
|
||||
"insomnia-importers",
|
||||
"jsonpath",
|
||||
"mkdirp",
|
||||
"nedb",
|
||||
"node-forge",
|
||||
"node-libcurl",
|
||||
"srp-js",
|
||||
"tar",
|
||||
"tough-cookie",
|
||||
"vkbeautify"
|
||||
]
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
const webpack = require('webpack');
|
||||
const path = require('path');
|
||||
const pkg = require('../app/package.json');
|
||||
const pkg = require('../package.json');
|
||||
|
||||
module.exports = {
|
||||
devtool: 'source-map',
|
||||
@ -54,12 +54,11 @@ module.exports = {
|
||||
},
|
||||
externals: [
|
||||
// Omit all dependencies in app/package.json (we want them loaded at runtime via NodeJS)
|
||||
...Object.keys(pkg.dependencies),
|
||||
...pkg.externals,
|
||||
|
||||
// To get jsonlint working...
|
||||
'file', 'system'
|
||||
],
|
||||
plugins: [
|
||||
],
|
||||
plugins: [],
|
||||
target: 'electron-renderer'
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user