mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
parent
513245245e
commit
2e5b963e89
@ -12,13 +12,14 @@ import tls from 'tls';
|
||||
import { parse as urlParse } from 'url';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
import { version } from '../../../package.json';
|
||||
import { AUTH_AWS_IAM, AUTH_DIGEST, AUTH_NETRC, AUTH_NTLM, CONTENT_TYPE_FORM_DATA, CONTENT_TYPE_FORM_URLENCODED } from '../../common/constants';
|
||||
import { describeByteSize, hasAuthHeader } from '../../common/misc';
|
||||
import { ClientCertificate } from '../../models/client-certificate';
|
||||
import { RequestHeader } from '../../models/request';
|
||||
import { ResponseHeader } from '../../models/response';
|
||||
import { buildMultipart } from './multipart';
|
||||
import { parseHeaderStrings } from './parse-header-strings';
|
||||
|
||||
export interface CurlRequestOptions {
|
||||
requestId: string; // for cancellation
|
||||
req: RequestUsedHere;
|
||||
@ -370,10 +371,12 @@ export const createConfiguredCurlInstance = ({
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// suppress node-libcurl default user-agent
|
||||
curl.setOpt(Curl.option.USERAGENT, '');
|
||||
const { headers, authentication } = req;
|
||||
|
||||
const userAgent: RequestHeader | null = headers.find((h: any) => h.name.toLowerCase() === 'user-agent') || null;
|
||||
const userAgentOrFallback = typeof userAgent?.value === 'string' ? userAgent?.value : 'insomnia/' + version;
|
||||
curl.setOpt(Curl.option.USERAGENT, userAgentOrFallback);
|
||||
|
||||
const { username, password, disabled } = authentication;
|
||||
const isDigest = authentication.type === AUTH_DIGEST;
|
||||
const isNLTM = authentication.type === AUTH_NTLM;
|
||||
|
@ -4,6 +4,7 @@ import electron from 'electron';
|
||||
import fs from 'fs';
|
||||
import { join as pathJoin, resolve as pathResolve } from 'path';
|
||||
|
||||
import { version } from '../../../package.json';
|
||||
import { globalBeforeEach } from '../../__jest__/before-each';
|
||||
import {
|
||||
AUTH_AWS_IAM,
|
||||
@ -137,7 +138,7 @@ describe('sendCurlAndWriteTimeline()', () => {
|
||||
PROXY: '',
|
||||
TIMEOUT_MS: 30000,
|
||||
URL: 'http://localhost/?foo%20bar=hello%26world',
|
||||
USERAGENT: '',
|
||||
USERAGENT: `insomnia/${version}`,
|
||||
VERBOSE: true,
|
||||
},
|
||||
});
|
||||
@ -207,7 +208,7 @@ describe('sendCurlAndWriteTimeline()', () => {
|
||||
PROXY: '',
|
||||
TIMEOUT_MS: 30000,
|
||||
URL: 'http://localhost/',
|
||||
USERAGENT: '',
|
||||
USERAGENT: `insomnia/${version}`,
|
||||
VERBOSE: true,
|
||||
},
|
||||
});
|
||||
@ -308,7 +309,7 @@ describe('sendCurlAndWriteTimeline()', () => {
|
||||
PROXY: '',
|
||||
TIMEOUT_MS: 30000,
|
||||
URL: 'http://localhost/?foo%20bar=hello%26world',
|
||||
USERAGENT: '',
|
||||
USERAGENT: `insomnia/${version}`,
|
||||
VERBOSE: true,
|
||||
},
|
||||
});
|
||||
@ -372,7 +373,7 @@ describe('sendCurlAndWriteTimeline()', () => {
|
||||
TIMEOUT_MS: 30000,
|
||||
UPLOAD: 1,
|
||||
URL: 'http://localhost/',
|
||||
USERAGENT: '',
|
||||
USERAGENT: `insomnia/${version}`,
|
||||
VERBOSE: true,
|
||||
},
|
||||
});
|
||||
@ -465,7 +466,7 @@ describe('sendCurlAndWriteTimeline()', () => {
|
||||
TIMEOUT_MS: 30000,
|
||||
URL: 'http://localhost/',
|
||||
UPLOAD: 1,
|
||||
USERAGENT: '',
|
||||
USERAGENT: `insomnia/${version}`,
|
||||
VERBOSE: true,
|
||||
},
|
||||
});
|
||||
@ -506,7 +507,7 @@ describe('sendCurlAndWriteTimeline()', () => {
|
||||
TIMEOUT_MS: 30000,
|
||||
URL: 'http://my/path',
|
||||
UNIX_SOCKET_PATH: '/my/socket',
|
||||
USERAGENT: '',
|
||||
USERAGENT: `insomnia/${version}`,
|
||||
VERBOSE: true,
|
||||
},
|
||||
});
|
||||
@ -546,7 +547,7 @@ describe('sendCurlAndWriteTimeline()', () => {
|
||||
PROXY: '',
|
||||
TIMEOUT_MS: 30000,
|
||||
URL: 'http://localhost:3000/foo/bar',
|
||||
USERAGENT: '',
|
||||
USERAGENT: `insomnia/${version}`,
|
||||
VERBOSE: true,
|
||||
},
|
||||
});
|
||||
@ -586,7 +587,7 @@ describe('sendCurlAndWriteTimeline()', () => {
|
||||
PROXY: '',
|
||||
TIMEOUT_MS: 30000,
|
||||
URL: 'http://unix:3000/my/path',
|
||||
USERAGENT: '',
|
||||
USERAGENT: `insomnia/${version}`,
|
||||
VERBOSE: true,
|
||||
},
|
||||
});
|
||||
@ -628,7 +629,7 @@ describe('sendCurlAndWriteTimeline()', () => {
|
||||
TIMEOUT_MS: 30000,
|
||||
NETRC: CurlNetrc.Required,
|
||||
URL: '',
|
||||
USERAGENT: '',
|
||||
USERAGENT: `insomnia/${version}`,
|
||||
VERBOSE: true,
|
||||
},
|
||||
});
|
||||
@ -740,7 +741,7 @@ describe('sendCurlAndWriteTimeline()', () => {
|
||||
SSL_VERIFYPEER: 0, // should disable SSL
|
||||
TIMEOUT_MS: 30000,
|
||||
URL: 'http://localhost/?foo%20bar=hello%26world',
|
||||
USERAGENT: '',
|
||||
USERAGENT: `insomnia/${version}`,
|
||||
VERBOSE: true,
|
||||
},
|
||||
});
|
||||
|
@ -2,7 +2,6 @@ import crypto from 'crypto';
|
||||
import querystring from 'querystring';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
import { version } from '../../../package.json';
|
||||
import { escapeRegex } from '../../common/misc';
|
||||
import * as models from '../../models';
|
||||
import type { OAuth2Token } from '../../models/o-auth-2-token';
|
||||
@ -304,7 +303,6 @@ const sendAccessTokenRequest = async (requestId: string, authentication: AuthTyp
|
||||
headers: [
|
||||
{ name: 'Content-Type', value: 'application/x-www-form-urlencoded' },
|
||||
{ name: 'Accept', value: 'application/x-www-form-urlencoded, application/json' },
|
||||
{ name: 'User-Agent', value: 'insomnia/' + version },
|
||||
...headers,
|
||||
],
|
||||
url: setDefaultProtocol(authentication.accessTokenUrl),
|
||||
|
@ -105,7 +105,7 @@ export const createRequestAction: ActionFunction = async ({ request, params }) =
|
||||
parentId: parentId || workspaceId,
|
||||
method: METHOD_GET,
|
||||
name: 'New Request',
|
||||
headers: [{ name: 'User-Agent', value: `Insomnia/${version}` }],
|
||||
headers: [{ name: 'User-Agent', value: `insomnia/${version}` }],
|
||||
}))._id;
|
||||
}
|
||||
if (requestType === 'gRPC') {
|
||||
@ -119,7 +119,7 @@ export const createRequestAction: ActionFunction = async ({ request, params }) =
|
||||
parentId: parentId || workspaceId,
|
||||
method: METHOD_POST,
|
||||
headers: [
|
||||
{ name: 'User-Agent', value: `Insomnia/${version}` },
|
||||
{ name: 'User-Agent', value: `insomnia/${version}` },
|
||||
{ name: 'Content-Type', value: CONTENT_TYPE_JSON },
|
||||
],
|
||||
body: {
|
||||
@ -135,7 +135,7 @@ export const createRequestAction: ActionFunction = async ({ request, params }) =
|
||||
method: METHOD_GET,
|
||||
url: '',
|
||||
headers: [
|
||||
{ name: 'User-Agent', value: `Insomnia/${version}` },
|
||||
{ name: 'User-Agent', value: `insomnia/${version}` },
|
||||
{ name: 'Accept', value: CONTENT_TYPE_EVENT_STREAM },
|
||||
],
|
||||
name: 'New Event Stream',
|
||||
@ -145,7 +145,7 @@ export const createRequestAction: ActionFunction = async ({ request, params }) =
|
||||
activeRequestId = (await models.webSocketRequest.create({
|
||||
parentId: parentId || workspaceId,
|
||||
name: 'New WebSocket Request',
|
||||
headers: [{ name: 'User-Agent', value: `Insomnia/${version}` }],
|
||||
headers: [{ name: 'User-Agent', value: `insomnia/${version}` }],
|
||||
}))._id;
|
||||
}
|
||||
if (requestType === 'From Curl') {
|
||||
|
Loading…
Reference in New Issue
Block a user