mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 04:50:18 +00:00
[got] Add errorCodes to RetryOptions
This commit is contained in:
+20
-1
@@ -265,8 +265,27 @@ got('https://todomvc.com', { rejectUnauthorized: false });
|
||||
got('/examples/angularjs', { baseUrl: 'http://todomvc.com' });
|
||||
got('http://todomvc.com', { headers: { foo: 'bar'} });
|
||||
got('http://todomvc.com', { cookieJar: new tough.CookieJar() });
|
||||
|
||||
// Test retry options.
|
||||
got('http://todomvc.com', { retry: 2 });
|
||||
got('http://todomvc.com', { retry: { retries: 2, methods: ['GET'], statusCodes: [408, 504], maxRetryAfter: 1 } });
|
||||
got('http://todomvc.com', {
|
||||
retry: {
|
||||
retries: 2,
|
||||
methods: ['GET'],
|
||||
statusCodes: [408, 504],
|
||||
maxRetryAfter: 1,
|
||||
errorCodes: ['ETIMEDOUT']
|
||||
}
|
||||
});
|
||||
// Test custom retry error code. See https://github.com/sindresorhus/got/blob/9f3a09948ff80057b12af0af60846cc5b8f0372d/test/retry.js#L155
|
||||
got('http://todomvc.com', {
|
||||
retry: {
|
||||
retries: 1,
|
||||
methods: ['GET'],
|
||||
errorCodes: ['OH_SNAP']
|
||||
}
|
||||
});
|
||||
|
||||
got('http://todomvc.com', { throwHttpErrors: false });
|
||||
got('http://todomvc.com', { hooks: { beforeRequest: [ () => 'foo']} });
|
||||
|
||||
|
||||
Vendored
+5
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for got 9.3
|
||||
// Type definitions for got 9.4
|
||||
// Project: https://github.com/sindresorhus/got#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Linus Unnebäck <https://github.com/LinusU>
|
||||
@@ -226,6 +226,10 @@ declare namespace got {
|
||||
methods?: Array<'GET' | 'PUT' | 'HEAD' | 'DELETE' | 'OPTIONS' | 'TRACE'>;
|
||||
statusCodes?: Array<408 | 413 | 429 | 500 | 502 | 503 | 504>;
|
||||
maxRetryAfter?: number;
|
||||
/**
|
||||
* Allowed error codes.
|
||||
*/
|
||||
errorCodes?: string[];
|
||||
}
|
||||
|
||||
interface AgentOptions {
|
||||
|
||||
Reference in New Issue
Block a user