diff --git a/types/follow-redirects/follow-redirects-tests.ts b/types/follow-redirects/follow-redirects-tests.ts index 96219ad2a8..0f74722b79 100644 --- a/types/follow-redirects/follow-redirects-tests.ts +++ b/types/follow-redirects/follow-redirects-tests.ts @@ -5,6 +5,9 @@ http.request({ path: '/a/b', port: 8000, maxRedirects: 12, + beforeRedirect: (options) => { + options.followRedirects = false; + } }, (response) => { console.log(response.responseUrl, response.redirects); response.on('data', (chunk) => { diff --git a/types/follow-redirects/index.d.ts b/types/follow-redirects/index.d.ts index e7144e1f7f..9a935478c8 100644 --- a/types/follow-redirects/index.d.ts +++ b/types/follow-redirects/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for follow-redirects 1.5 +// Type definitions for follow-redirects 1.8 // Project: https://github.com/follow-redirects/follow-redirects -// Definitions by: Emily Klassen +// Definitions by: Emily Klassen , Claas Ahlrichs // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -70,19 +70,26 @@ export interface RedirectableRequest export interface RedirectScheme { request( - options: string | Options & FollowOptions, + options: string | Options & FollowOptions, callback?: (res: Response & FollowResponse) => void ): RedirectableRequest; get( - options: string | Options & FollowOptions, + options: string | Options & FollowOptions, callback?: (res: Response & FollowResponse) => void ): RedirectableRequest; } export type Override = Pick> & U; -export interface FollowOptions { +export interface FollowOptions { + followRedirects?: boolean; maxRedirects?: number; maxBodyLength?: number; + beforeRedirect?: (options: Options & FollowOptions) => void; + agents?: { + http?: coreHttp.Agent; + https?: coreHttps.Agent; + }; + trackRedirects?: boolean; } export interface FollowResponse {