🤖 Merge PR #46666 update(follow-redirects): expose headers and version bump by @peterblazejewicz

- expose headers information as of 1.13
- add maintainer
- minor DT header change
- tests amended

https://github.com/follow-redirects/follow-redirects/compare/v1.12.1...v1.13.0

Thanks!
This commit is contained in:
Piotr Błażejewicz (Peter Blazejewicz) 2020-08-11 21:57:37 +02:00 committed by GitHub
parent 3e69dd6158
commit ccd09fee0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 6 deletions

View File

@ -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);

View File

@ -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 <https://github.com/forivall>, Claas Ahlrichs <https://github.com/claasahl>
// Definitions by: Emily Klassen <https://github.com/forivall>
// Claas Ahlrichs <https://github.com/claasahl>
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
/// <reference types="node" />
@ -84,7 +85,7 @@ export interface FollowOptions<Options> {
followRedirects?: boolean;
maxRedirects?: number;
maxBodyLength?: number;
beforeRedirect?: (options: Options & FollowOptions<Options>) => void;
beforeRedirect?: (options: Options & FollowOptions<Options>, 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<typeof coreHttp, RedirectScheme<
coreHttp.RequestOptions,
coreHttp.ClientRequest,