mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
🤖 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:
parent
3e69dd6158
commit
ccd09fee0a
@ -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);
|
||||
|
||||
13
types/follow-redirects/index.d.ts
vendored
13
types/follow-redirects/index.d.ts
vendored
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user