Socket
Socket
Sign inDemoInstall

got

Package Overview
Dependencies
Maintainers
2
Versions
176
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

got - npm Package Compare versions

Comparing version 10.0.0-beta.2 to 10.0.0-beta.3

3

dist/source/as-promise.js

@@ -60,3 +60,3 @@ "use strict";

for (const [index, hook] of options.hooks.afterResponse.entries()) {
// @ts-ignore
// @ts-ignore Promise is not assignable to CancelableRequest
// eslint-disable-next-line no-await-in-loop

@@ -133,3 +133,2 @@ response = await hook(response, async (updatedOptions) => {

Object.defineProperties(newPromise, Object.getOwnPropertyDescriptors(promise));
// @ts-ignore The missing properties are added above
return newPromise;

@@ -136,0 +135,0 @@ };

@@ -25,3 +25,3 @@ "use strict";

const proxy = duplexer3(input, output);
const piped = new Set(); // TODO: Should be `new Set<stream.Writable>();`.
const piped = new Set();
let isFinished = false;

@@ -106,3 +106,3 @@ options.retry.calculateDelay = () => 0;

pipe(destination, options);
if (Reflect.has(destination, 'setHeader')) {
if (destination instanceof http_1.ServerResponse) {
piped.add(destination);

@@ -109,0 +109,0 @@ }

@@ -8,3 +8,2 @@ "use strict";

const calculateRetryDelay = ({ attemptCount, retryOptions, error }) => {
var _a, _b;
if (attemptCount > retryOptions.limit) {

@@ -15,3 +14,3 @@ return 0;

const hasErrorCode = Reflect.has(error, 'code') && retryOptions.errorCodes.includes(error.code);
const hasStatusCode = isErrorWithResponse(error) && Reflect.has(error, 'response') && retryOptions.statusCodes.includes((_a = error.response) === null || _a === void 0 ? void 0 : _a.statusCode);
const hasStatusCode = isErrorWithResponse(error) && retryOptions.statusCodes.includes(error.response.statusCode);
if (!hasMethod || (!hasErrorCode && !hasStatusCode)) {

@@ -35,3 +34,3 @@ return 0;

}
if (((_b = response) === null || _b === void 0 ? void 0 : _b.statusCode) === 413) {
if (response.statusCode === 413) {
return 0;

@@ -38,0 +37,0 @@ }

@@ -5,3 +5,3 @@ /// <reference types="node" />

import * as errors from './errors';
import { CancelableRequest, ExtendOptions, HandlerFunction, NormalizedDefaults, Options, Response, URLOrOptions } from './utils/types';
import { CancelableRequest, Defaults, ExtendOptions, HandlerFunction, Options, Response, URLOrOptions } from './utils/types';
export declare type HTTPAlias = 'get' | 'post' | 'put' | 'patch' | 'head' | 'delete';

@@ -54,3 +54,3 @@ export declare type ReturnStream = <T>(url: string | Merge<Options, {

stream: GotStream;
defaults: NormalizedDefaults | Readonly<NormalizedDefaults>;
defaults: Defaults | Readonly<Defaults>;
GotError: typeof errors.GotError;

@@ -74,5 +74,3 @@ CacheError: typeof errors.CacheError;

export declare const defaultHandler: HandlerFunction;
declare const create: (defaults: NormalizedDefaults & {
_rawHandlers?: HandlerFunction[] | undefined;
}) => Got;
declare const create: (defaults: Defaults) => Got;
export default create;

@@ -21,2 +21,3 @@ "use strict";

// Proxy properties from next handlers
// @ts-ignore Internal use only.
defaults._rawHandlers = defaults.handlers;

@@ -45,2 +46,3 @@ defaults.handlers = defaults.handlers.map(fn => ((options, next) => {

};
/* eslint-disable @typescript-eslint/return-await */
try {

@@ -58,5 +60,7 @@ return iterateHandlers(normalize_arguments_1.normalizeArguments(url, options, defaults));

}
/* eslint-enable @typescript-eslint/return-await */
};
got.extend = (...instancesOrOptions) => {
const optionsArray = [defaults.options];
// @ts-ignore Internal use only.
let handlers = [...defaults._rawHandlers];

@@ -67,2 +71,3 @@ let mutableDefaults;

optionsArray.push(value.defaults.options);
// @ts-ignore Internal use only.
handlers.push(...value.defaults._rawHandlers);

@@ -92,3 +97,3 @@ mutableDefaults = value.defaults.mutableDefaults;

for (const method of aliases) {
// @ts-ignore
// @ts-ignore GotReturn<Response> does not equal GotReturn<T>
got[method] = (url, options) => got(url, { ...options, method });

@@ -95,0 +100,0 @@ got.stream[method] = (url, options) => got.stream(url, { ...options, method });

@@ -61,3 +61,6 @@ "use strict";

maxRedirects: 10,
prefixUrl: ''
prefixUrl: '',
methodRewriting: true,
ignoreInvalidCookies: false,
context: {}
},

@@ -64,0 +67,0 @@ handlers: [create_1.defaultHandler],

/// <reference types="node" />
import http = require('http');
import https = require('https');
import stream = require('stream');
import { Merge } from 'type-fest';
import { Defaults, NormalizedOptions, Options, URLOrOptions } from './utils/types';
export declare const preNormalizeArguments: (options: Options, defaults?: NormalizedOptions | undefined) => NormalizedOptions;
export declare const mergeOptions: (...sources: Options[]) => NormalizedOptions;
export declare const normalizeArguments: (url: URLOrOptions, options?: Options | undefined, defaults?: Defaults | undefined) => NormalizedOptions;
import { Defaults, NormalizedOptions, RequestFunction, URLOrOptions } from './utils/types';
export declare const preNormalizeArguments: (options: Merge<https.RequestOptions, Merge<import("./utils/types").GotOptions, import("./utils/options-to-url").URLOptions>>, defaults?: NormalizedOptions | undefined) => NormalizedOptions;
export declare const mergeOptions: (...sources: Merge<https.RequestOptions, Merge<import("./utils/types").GotOptions, import("./utils/options-to-url").URLOptions>>[]) => NormalizedOptions;
export declare const normalizeArguments: (url: URLOrOptions, options?: Merge<https.RequestOptions, Merge<import("./utils/types").GotOptions, import("./utils/options-to-url").URLOptions>> | undefined, defaults?: Defaults | undefined) => NormalizedOptions;
export declare type NormalizedRequestArguments = Merge<https.RequestOptions, {
body?: ReadableStream;
body?: stream.Readable;
request: RequestFunction;
url: Pick<NormalizedOptions, 'url'>;
}>;
export declare const normalizeRequestArguments: (options: NormalizedOptions) => Promise<Merge<https.RequestOptions, {
body?: ReadableStream<any> | undefined;
body?: stream.Readable | undefined;
request: typeof http.request;
url: Pick<NormalizedOptions, "url">;
}>>;

@@ -26,4 +26,5 @@ "use strict";

const isAgentByProtocol = (agent) => is_1.default.object(agent);
// TODO: `preNormalizeArguments` should merge `options` & `defaults`
exports.preNormalizeArguments = (options, defaults) => {
var _a;
var _a, _b;
// `options.headers`

@@ -36,2 +37,7 @@ if (is_1.default.undefined(options.headers)) {

}
for (const [key, value] of Object.entries(options.headers)) {
if (is_1.default.null_(value)) {
throw new TypeError(`Use \`undefined\` instead of \`null\` to delete the \`${key}\` header`);
}
}
// `options.prefixUrl`

@@ -68,7 +74,9 @@ if (is_1.default.urlInstance(options.prefixUrl) || is_1.default.string(options.prefixUrl)) {

for (const event of known_hook_events_1.default) {
// @ts-ignore TS is dumb.
options.hooks[event] = [
...defaults.hooks[event],
...options.hooks[event]
];
if (!(Reflect.has(options.hooks, event) && is_1.default.undefined(options.hooks[event]))) {
// @ts-ignore Union type array is not assignable to union array type
options.hooks[event] = [
...defaults.hooks[event],
...options.hooks[event]
];
}
}

@@ -108,3 +116,3 @@ }

if (options.retry.maxRetryAfter === undefined) {
// @ts-ignore We assign if it is undefined, so this is correct
// @ts-ignore We assign if it is undefined, so this IS correct
options.retry.maxRetryAfter = Math.min(...[options.timeout.request, options.timeout.connect].filter((n) => !is_1.default.nullOrUndefined(n)));

@@ -124,3 +132,3 @@ }

else {
options.method = ((_a = defaults) === null || _a === void 0 ? void 0 : _a.method) || 'GET';
options.method = (_b = (_a = defaults) === null || _a === void 0 ? void 0 : _a.method, (_b !== null && _b !== void 0 ? _b : 'GET'));
}

@@ -139,3 +147,3 @@ // Better memory management, so we don't have to generate a new object every time

if (!Reflect.has(setCookie, util_1.promisify.custom)) {
// @ts-ignore TS is dumb.
// @ts-ignore We check for non-promisified setCookie, so this IS correct
setCookie = util_1.promisify(setCookie.bind(options.cookieJar));

@@ -157,2 +165,6 @@ getCookieString = util_1.promisify(getCookieString.bind(options.cookieJar));

}
// `options.maxRedirects`
if (!Reflect.has(options, 'maxRedirects') && !(defaults && Reflect.has(defaults, 'maxRedirects'))) {
options.maxRedirects = 0;
}
return options;

@@ -165,5 +177,2 @@ };

for (const source of sources) {
if (!source) {
continue;
}
merge_1.default(mergedOptions, exports.preNormalizeArguments(merge_1.default({}, source), mergedOptions));

@@ -186,3 +195,3 @@ for (const name of nonEnumerableProperties) {

exports.normalizeArguments = (url, options, defaults) => {
var _a, _b;
var _a, _b, _c, _d;
// Merge options

@@ -197,3 +206,3 @@ if (typeof url === 'undefined') {

options.url = url;
options = exports.mergeOptions((_a = (defaults && defaults.options), (_a !== null && _a !== void 0 ? _a : {})), options);
options = exports.mergeOptions((_b = (_a = defaults) === null || _a === void 0 ? void 0 : _a.options, (_b !== null && _b !== void 0 ? _b : {})), options);
}

@@ -204,3 +213,3 @@ else {

}
options = exports.mergeOptions((_b = (defaults && defaults.options), (_b !== null && _b !== void 0 ? _b : {})), url, options);
options = exports.mergeOptions((_d = (_c = defaults) === null || _c === void 0 ? void 0 : _c.options, (_d !== null && _d !== void 0 ? _d : {})), url, options);
}

@@ -239,14 +248,11 @@ // Normalize URL

if (is_1.default.undefined(value)) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete normalizedOptions.headers[key];
}
else if (is_1.default.null_(value)) {
throw new TypeError('Use `undefined` instead of `null` to delete HTTP headers');
}
}
for (const hook of normalizedOptions.hooks.init) {
if (is_1.default.asyncFunction(hook)) {
const result = hook(normalizedOptions);
if (is_1.default.promise(result)) {
throw new TypeError('The `init` hook must be a synchronous function');
}
// @ts-ignore TS is dumb.
hook(normalizedOptions);
}

@@ -257,33 +263,37 @@ return normalizedOptions;

exports.normalizeRequestArguments = async (options) => {
var _a, _b;
var _a, _b, _c;
options = exports.mergeOptions(options);
// Serialize body
const { headers } = options;
const isForm = !is_1.default.undefined(options.form);
const isJSON = !is_1.default.undefined(options.json);
const isBody = !is_1.default.undefined(options.body);
if ((isBody || isForm || isJSON) && withoutBody.has(options.method)) {
throw new TypeError(`The \`${options.method}\` method cannot be used with a body`);
}
if ([isBody, isForm, isJSON].filter(isTrue => isTrue).length > 1) {
throw new TypeError('The `body`, `json` and `form` options are mutually exclusive');
}
if (isBody) {
if (is_1.default.object(options.body) && is_form_data_1.default(options.body)) {
// Special case for https://github.com/form-data/form-data
if (!Reflect.has(headers, 'content-type')) {
// @ts-ignore TS is dumb.
headers['content-type'] = `multipart/form-data; boundary=${options.body.getBoundary()}`;
}
const noContentType = is_1.default.undefined(headers['content-type']);
{
// TODO: these checks should be moved to `preNormalizeArguments`
const isForm = !is_1.default.undefined(options.form);
const isJSON = !is_1.default.undefined(options.json);
const isBody = !is_1.default.undefined(options.body);
if ((isBody || isForm || isJSON) && withoutBody.has(options.method)) {
throw new TypeError(`The \`${options.method}\` method cannot be used with a body`);
}
else if (!is_1.default.nodeStream(options.body) && !is_1.default.string(options.body) && !is_1.default.buffer(options.body)) {
if ([isBody, isForm, isJSON].filter(isTrue => isTrue).length > 1) {
throw new TypeError('The `body`, `json` and `form` options are mutually exclusive');
}
if (isBody &&
!is_1.default.nodeStream(options.body) &&
!is_1.default.string(options.body) &&
!is_1.default.buffer(options.body) &&
!(is_1.default.object(options.body) && is_form_data_1.default(options.body))) {
throw new TypeError('The `body` option must be a stream.Readable, string or Buffer');
}
}
else if (isForm) {
if (!is_1.default.object(options.form)) {
if (isForm && !is_1.default.object(options.form)) {
throw new TypeError('The `form` option must be an Object');
}
if (!Reflect.has(headers, 'content-type')) {
// @ts-ignore TS is dumb.
}
if (options.body) {
// Special case for https://github.com/form-data/form-data
if (is_1.default.object(options.body) && is_form_data_1.default(options.body) && noContentType) {
headers['content-type'] = `multipart/form-data; boundary=${options.body.getBoundary()}`;
}
}
else if (options.form) {
if (noContentType) {
headers['content-type'] = 'application/x-www-form-urlencoded';

@@ -293,5 +303,4 @@ }

}
else if (isJSON) {
if (!Reflect.has(headers, 'content-type')) {
// @ts-ignore TS is dumb.
else if (options.json) {
if (noContentType) {
headers['content-type'] = 'application/json';

@@ -314,6 +323,6 @@ }

// body.
if (!Reflect.has(headers, 'content-length') && !Reflect.has(headers, 'transfer-encoding')) {
if (noContentType && is_1.default.undefined(headers['transfer-encoding'])) {
if ((options.method === 'POST' || options.method === 'PUT' || options.method === 'PATCH') &&
!is_1.default.undefined(uploadBodySize)) {
// @ts-ignore TS is dumb.
// @ts-ignore We assign if it is undefined, so this IS correct
headers['content-length'] = String(uploadBodySize);

@@ -342,4 +351,2 @@ }

const { socketPath, path } = matches.groups;
// It's a bug!
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
options = {

@@ -354,3 +361,3 @@ ...options,

if (isAgentByProtocol(options.agent)) {
options.agent = options.agent[options.url.protocol.slice(0, -1)] || options.agent;
options.agent = (_b = options.agent[options.url.protocol.slice(0, -1)], (_b !== null && _b !== void 0 ? _b : options.agent));
}

@@ -365,3 +372,3 @@ if (options.dnsCache) {

const electron = dynamic_require_1.default(module, 'electron'); // Trick webpack
options.request = (_b = electron.net.request, (_b !== null && _b !== void 0 ? _b : electron.remote.net.request));
options.request = (_c = electron.net.request, (_c !== null && _c !== void 0 ? _c : electron.remote.net.request));
}

@@ -368,0 +375,0 @@ // Got's `timeout` is an object, http's `timeout` is a number, so they're not compatible.

@@ -17,3 +17,3 @@ "use strict";

const url_to_options_1 = require("./utils/url-to-options");
const setImmediateAsync = () => new Promise(resolve => setImmediate(resolve));
const setImmediateAsync = async () => new Promise(resolve => setImmediate(resolve));
const pipeline = util_1.promisify(stream.pipeline);

@@ -58,4 +58,3 @@ const redirectCodes = new Set([300, 301, 302, 303, 304, 307, 308]);

const { statusCode } = typedResponse;
// This is intentionally using `||` over `??` so it can also catch empty status message.
typedResponse.statusMessage = typedResponse.statusMessage || http.STATUS_CODES[statusCode];
typedResponse.statusMessage = is_1.default.nonEmptyString(typedResponse.statusMessage) ? typedResponse.statusMessage : http.STATUS_CODES[statusCode];
typedResponse.url = options.url.toString();

@@ -74,5 +73,5 @@ typedResponse.requestUrl = requestURL;

if (Reflect.has(options, 'cookieJar') && rawCookies) {
let promises = rawCookies.map((rawCookie) => options.cookieJar.setCookie(rawCookie, typedResponse.url));
let promises = rawCookies.map(async (rawCookie) => options.cookieJar.setCookie(rawCookie, typedResponse.url));
if (options.ignoreInvalidCookies) {
promises = promises.map(p => p.catch(() => { }));
promises = promises.map(async (p) => p.catch(() => { }));
}

@@ -83,3 +82,3 @@ await Promise.all(promises);

typedResponse.resume(); // We're being redirected, we don't care about the response.
if (statusCode === 303) {
if (statusCode === 303 || options.methodRewriting === false) {
if (options.method !== 'GET' && options.method !== 'HEAD') {

@@ -149,5 +148,3 @@ // Server responded with "see other", indicating that the resource exists at another location,

const uploadStream = progress_1.createProgressStream('uploadProgress', emitter, httpOptions.headers['content-length']);
await pipeline(
// @ts-ignore Cannot assign ReadableStream to ReadableStream
httpOptions.body, uploadStream, request);
await pipeline(httpOptions.body, uploadStream, request);
attachErrorHandler();

@@ -187,4 +184,3 @@ request.emit('upload-complete');

try {
// @ts-ignore 1. TS complains that URLSearchParams is not the same as URLSearchParams.
// 2. It doesn't notice that `options.timeout` is deleted above.
// @ts-ignore URLSearchParams does not equal URLSearchParams
handleRequest(httpOptions.request(options.url, httpOptions, handleResponse));

@@ -191,0 +187,0 @@ }

@@ -1,3 +0,3 @@

import { Options } from './types';
declare const _default: (options: Options) => Promise<number | undefined>;
/// <reference types="node" />
declare const _default: (options: import("type-fest").Merge<import("https").RequestOptions, import("type-fest").Merge<import("./types").GotOptions, import("./options-to-url").URLOptions>>) => Promise<number | undefined>;
export default _default;

@@ -9,3 +9,3 @@ "use strict";

if (is_1.default.urlInstance(targetValue) && is_1.default.string(sourceValue)) {
// @ts-ignore
// @ts-ignore TS doesn't recognise Target accepts string keys
target[key] = new URL(sourceValue, targetValue);

@@ -15,7 +15,7 @@ }

if (is_1.default.plainObject(targetValue)) {
// @ts-ignore
// @ts-ignore TS doesn't recognise Target accepts string keys
target[key] = merge({}, targetValue, sourceValue);
}
else {
// @ts-ignore
// @ts-ignore TS doesn't recognise Target accepts string keys
target[key] = merge({}, sourceValue);

@@ -25,7 +25,7 @@ }

else if (is_1.default.array(sourceValue)) {
// @ts-ignore
// @ts-ignore TS doesn't recognise Target accepts string keys
target[key] = sourceValue.slice();
}
else {
// @ts-ignore
// @ts-ignore TS doesn't recognise Target accepts string keys
target[key] = sourceValue;

@@ -32,0 +32,0 @@ }

@@ -6,3 +6,3 @@ "use strict";

if (typeof value !== 'string' && typeof value !== 'number' && typeof value !== 'boolean' && value !== null) {
throw new TypeError(`The \`searchParams\` value '${value}' must be a string, number, boolean or null`);
throw new TypeError(`The \`searchParams\` value '${String(value)}' must be a string, number, boolean or null`);
}

@@ -23,2 +23,3 @@ }

exports.default = (options) => {
var _a, _b;
let origin;

@@ -44,3 +45,3 @@ if (Reflect.has(options, 'path')) {

}
origin = `${options.protocol}//${options.hostname || options.host}`;
origin = `${options.protocol}//${_b = (_a = options.hostname, (_a !== null && _a !== void 0 ? _a : options.host)), (_b !== null && _b !== void 0 ? _b : '')}`;
}

@@ -47,0 +48,0 @@ const url = new URL(origin);

@@ -9,5 +9,5 @@ /// <reference types="node" />

import { Readable as ReadableStream } from 'stream';
import { Timings } from '@szmarczak/http-timer';
import CacheableLookup from 'cacheable-lookup';
import { Timings } from '@szmarczak/http-timer';
import { Except, Merge } from 'type-fest';
import { Except, Merge, Promisable } from 'type-fest';
import { GotReturn } from '../create';

@@ -54,3 +54,3 @@ import { GotError, HTTPError, MaxRedirectsError, ParseError } from '../errors';

export declare type RetryFunction = (retryObject: RetryObject) => number;
export declare type HandlerFunction = <T extends GotReturn>(options: NormalizedOptions, next: (options: NormalizedOptions) => T) => T;
export declare type HandlerFunction = <T extends GotReturn>(options: NormalizedOptions, next: (options: NormalizedOptions) => T) => Promisable<T>;
export interface DefaultRetryOptions {

@@ -61,3 +61,3 @@ limit: number;

errorCodes: string[];
calculateDelay?: RetryFunction;
calculateDelay: RetryFunction;
maxRetryAfter?: number;

@@ -68,3 +68,3 @@ }

}
export declare type RequestFunction = typeof https.request;
export declare type RequestFunction = typeof http.request;
export interface AgentByProtocol {

@@ -84,32 +84,28 @@ http?: http.Agent;

export declare type Headers = Record<string, string | string[] | undefined>;
interface CookieJar {
interface ToughCookieJar {
getCookieString(currentUrl: string, options: {
[key: string]: unknown;
}, cb: (err: Error | null, cookies: string) => void): void;
getCookieString(url: string, callback: (error: Error | null, cookieHeader: string) => void): void;
setCookie(cookieOrString: unknown, currentUrl: string, options: {
[key: string]: unknown;
}, cb: (err: Error | null, cookie: unknown) => void): void;
setCookie(rawCookie: string, url: string, callback: (error: Error | null, result: unknown) => void): void;
}
interface PromiseCookieJar {
getCookieString(url: string): Promise<string>;
setCookie(rawCookie: string, url: string, callback: (error: Error | null, result: unknown) => void): void;
setCookie(rawCookie: string, url: string): Promise<unknown>;
}
export interface DefaultOptions {
method: Method;
retry: DefaultRetryOptions | number;
timeout: Delays | number;
headers: Headers;
hooks: Hooks;
decompress: boolean;
throwHttpErrors: boolean;
followRedirect: boolean;
isStream: boolean;
cache: CacheableRequest.StorageAdapter | string | false;
dnsCache: CacheableLookup | Map<string, string> | Keyv | false;
useElectronNet: boolean;
responseType: ResponseType;
resolveBodyOnly: boolean;
maxRedirects: number;
prefixUrl: URL | string;
}
export interface Options extends Partial<Except<DefaultOptions, 'retry'>>, Merge<Except<https.RequestOptions, 'agent' | 'timeout'>, URLOptions> {
export declare type DefaultOptions = Merge<Required<Except<GotOptions, 'hooks' | 'retry' | 'timeout' | 'context' | 'agent' | 'body' | 'cookieJar' | 'encoding' | 'form' | 'json' | 'lookup' | 'request' | 'url'>>, {
hooks: Required<Hooks>;
retry: DefaultRetryOptions;
timeout: Delays;
context: {
[key: string]: any;
};
}>;
export interface GotOptions {
url?: URL | string;
body?: string | Buffer | ReadableStream;
hostname?: string;
socketPath?: string;
hooks?: Partial<Hooks>;
hooks?: Hooks;
decompress?: boolean;

@@ -121,3 +117,3 @@ isStream?: boolean;

throwHttpErrors?: boolean;
cookieJar?: CookieJar;
cookieJar?: ToughCookieJar | PromiseCookieJar;
ignoreInvalidCookies?: boolean;

@@ -146,4 +142,6 @@ request?: RequestFunction;

lookup?: CacheableLookup['lookup'];
methodRewriting?: boolean;
}
export interface NormalizedOptions extends Except<DefaultOptions, 'dnsCache'>, Except<Options, keyof DefaultOptions> {
export declare type Options = Merge<https.RequestOptions, Merge<GotOptions, URLOptions>>;
export interface NormalizedOptions extends Options {
headers: Headers;

@@ -153,2 +151,3 @@ hooks: Required<Hooks>;

dnsCache?: CacheableLookup | false;
lookup?: CacheableLookup['lookup'];
retry: Required<RetryOptions>;

@@ -159,2 +158,4 @@ prefixUrl: string;

cacheableRequest?: (options: string | URL | http.RequestOptions, callback?: (response: http.ServerResponse | ResponseLike) => void) => CacheableRequest.Emitter;
cookieJar?: PromiseCookieJar;
maxRedirects: number;
path?: string;

@@ -167,17 +168,6 @@ }

export interface Defaults {
options: Merge<Options, {
headers: Headers;
hooks: Required<Hooks>;
}>;
options: DefaultOptions;
handlers: HandlerFunction[];
mutableDefaults: boolean;
}
export interface NormalizedDefaults {
options: Merge<Options, {
headers: Headers;
hooks: Required<Hooks>;
}>;
handlers: HandlerFunction[];
_rawHandlers?: HandlerFunction[];
mutableDefaults: boolean;
}

@@ -184,0 +174,0 @@ export declare type URLOrOptions = Options | string;

{
"name": "got",
"version": "10.0.0-beta.2",
"version": "10.0.0-beta.3",
"description": "Simplified HTTP requests",

@@ -60,9 +60,9 @@ "license": "MIT",

"@types/express": "^4.17.2",
"@types/lolex": "^3.1.1",
"@types/node": "^12.12.8",
"@types/lolex": "^5.1.0",
"@types/node": "^12.12.14",
"@types/proxyquire": "^1.3.28",
"@types/sinon": "^7.0.13",
"@types/tough-cookie": "^2.3.5",
"@typescript-eslint/eslint-plugin": "^2.7.0",
"@typescript-eslint/parser": "^2.7.0",
"@typescript-eslint/eslint-plugin": "^2.9.0",
"@typescript-eslint/parser": "^2.9.0",
"ava": "^2.4.0",

@@ -73,3 +73,3 @@ "coveralls": "^3.0.4",

"delay": "^4.3.0",
"eslint-config-xo-typescript": "^0.21.0",
"eslint-config-xo-typescript": "^0.23.0",
"express": "^4.17.1",

@@ -123,6 +123,2 @@ "form-data": "^3.0.0",

],
"rules": {
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/promise-function-async": "off"
},
"ignores": [

@@ -129,0 +125,0 @@ "documentation/examples/*"

@@ -137,10 +137,12 @@ <div align="center">

When specified, `prefixUrl` will be prepended to `url`. The prefix can be any valid URL, either relative or absolute. A trailing slash `/` is optional, one will be added automatically, if needed, when joining `prefixUrl` and `url`. The `url` argument cannot start with a `/` when using this option.
When specified, `prefixUrl` will be prepended to `url`. The prefix can be any valid URL, either relative or absolute. A trailing slash `/` is optional - one will be added automatically.
Useful when used with `got.extend()` to create niche-specific Got-instances.
**Note:** `prefixUrl` will be ignored if the `url` argument is a URL instance.
**Tip:** If the input URL still contains the initial `prefixUrl`, you can change it as many times as you want. Otherwise it will throw an error.
**Note:** Leading slashes in `input` are disallowed when using this option to enforce consistency and avoid confusion. For example, when the prefix URL is `https://example.com/foo` and the input is `/bar`, there's ambiguity whether the resulting URL would become `https://example.com/foo/bar` or `https://example.com/bar`. The latter is used by browsers.
**Tip:** Useful when used with [`got.extend()`](#custom-endpoints) to create niche-specific Got-instances.
**Tip:** You can change `prefixUrl` using hooks as long as the URL still includes the `prefixUrl`. If the URL doesn't include it anymore, it will throw.
```js

@@ -414,4 +416,9 @@ const got = require('got');

This supports [method rewriting](https://tools.ietf.org/html/rfc7231#section-6.4). For example, when sending a POST request and receiving a `302`, it will resend that request to the new location.
###### methodRewriting
Type: `boolean`<br>
Default: `true`
By default, redirects will use [method rewriting](https://tools.ietf.org/html/rfc7231#section-6.4). For example, when sending a POST request and receiving a `302`, it will resend the body to the new location using the same HTTP method (`POST` in this case).
###### maxRedirects

@@ -1310,3 +1317,3 @@

t.true(is.number(attemptCount));
return attemptCount < 2;
return attemptCount < 2 ? 1 : 0;
}

@@ -1313,0 +1320,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc