From cfb61d28ad32f00e4adcc2e82bba67be16fca0a8 Mon Sep 17 00:00:00 2001 From: Jesse Rogers Date: Tue, 12 Mar 2019 13:56:14 -0400 Subject: [PATCH] [superagent] Add #maxResponseSize method to SuperAgent.Request (#33668) --- types/superagent/index.d.ts | 1 + types/superagent/superagent-tests.ts | 6 ++++++ types/superagent/v2/index.d.ts | 1 + types/superagent/v2/superagent-tests.ts | 6 ++++++ 4 files changed, 14 insertions(+) diff --git a/types/superagent/index.d.ts b/types/superagent/index.d.ts index 3c6dbaec8c..fd314a3a32 100644 --- a/types/superagent/index.d.ts +++ b/types/superagent/index.d.ts @@ -158,6 +158,7 @@ declare namespace request { use(fn: Plugin): this; withCredentials(): this; write(data: string | Buffer, encoding?: string): this; + maxResponseSize(size: number): this; } type Plugin = (req: SuperAgentRequest) => void; diff --git a/types/superagent/superagent-tests.ts b/types/superagent/superagent-tests.ts index e7b032907a..4ecc0ca2a0 100644 --- a/types/superagent/superagent-tests.ts +++ b/types/superagent/superagent-tests.ts @@ -168,6 +168,12 @@ request.get('/user') request.get('/user') .accept('png'); +// Setting max response size +request + .get('/search') + .maxResponseSize(1000) + .end(callback); + // Query strings request .post('/') diff --git a/types/superagent/v2/index.d.ts b/types/superagent/v2/index.d.ts index 140ae0aefc..e2b8438080 100644 --- a/types/superagent/v2/index.d.ts +++ b/types/superagent/v2/index.d.ts @@ -119,6 +119,7 @@ declare namespace request { withCredentials(): this; write(data: string | Buffer, encoding?: string): this; parse(fn: (res: Response, callback: (err: Error | null, body: any) => void) => void): this; + maxResponseSize(size: number): this; } type Plugin = (req: Request) => void; diff --git a/types/superagent/v2/superagent-tests.ts b/types/superagent/v2/superagent-tests.ts index a9ff954e4d..32fd6fe333 100644 --- a/types/superagent/v2/superagent-tests.ts +++ b/types/superagent/v2/superagent-tests.ts @@ -163,6 +163,12 @@ request.get('/user') request.get('/user') .accept('png'); +// Setting max response size +request + .get('/search') + .maxResponseSize(1000) + .end(callback); + // Query strings request .post('/')