diff --git a/types/follow-redirects/follow-redirects-tests.ts b/types/follow-redirects/follow-redirects-tests.ts index 0f74722b79..ca56e5da94 100644 --- a/types/follow-redirects/follow-redirects-tests.ts +++ b/types/follow-redirects/follow-redirects-tests.ts @@ -5,9 +5,10 @@ http.request({ path: '/a/b', port: 8000, maxRedirects: 12, - beforeRedirect: (options) => { + beforeRedirect: (options, { headers }) => { + headers; // $ExpectType IncomingHttpHeaders options.followRedirects = false; - } + }, }, (response) => { console.log(response.responseUrl, response.redirects); response.on('data', (chunk) => { @@ -17,6 +18,9 @@ http.request({ console.error(err); }); +const request = http.request({}); +request.end(); + http.get('http://bit.ly/900913', (response) => { response.on('data', (chunk) => { console.log(chunk); diff --git a/types/follow-redirects/index.d.ts b/types/follow-redirects/index.d.ts index 9a935478c8..357e65e41a 100644 --- a/types/follow-redirects/index.d.ts +++ b/types/follow-redirects/index.d.ts @@ -1,8 +1,9 @@ -// Type definitions for follow-redirects 1.8 +// Type definitions for follow-redirects 1.13 // Project: https://github.com/follow-redirects/follow-redirects -// Definitions by: Emily Klassen , Claas Ahlrichs +// Definitions by: Emily Klassen +// Claas Ahlrichs +// Piotr Błażejewicz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 /// @@ -84,7 +85,7 @@ export interface FollowOptions { followRedirects?: boolean; maxRedirects?: number; maxBodyLength?: number; - beforeRedirect?: (options: Options & FollowOptions) => void; + beforeRedirect?: (options: Options & FollowOptions, responseDetails: ResponseDetails) => void; agents?: { http?: coreHttp.Agent; https?: coreHttps.Agent; @@ -103,6 +104,10 @@ export interface Redirect { statusCode: number; } +export interface ResponseDetails { + headers: coreHttp.IncomingHttpHeaders; +} + export const http: Override