1 | ;
|
2 | /**
|
3 | * -------------------------------------------------------------------------------------------
|
4 | * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
|
5 | * See License in the project root for license information.
|
6 | * -------------------------------------------------------------------------------------------
|
7 | */
|
8 | Object.defineProperty(exports, "__esModule", { value: true });
|
9 | exports.RedirectHandlerOptions = void 0;
|
10 | /**
|
11 | * @class
|
12 | * @implements MiddlewareOptions
|
13 | * A class representing RedirectHandlerOptions
|
14 | */
|
15 | var RedirectHandlerOptions = /** @class */ (function () {
|
16 | /**
|
17 | * @public
|
18 | * @constructor
|
19 | * To create an instance of RedirectHandlerOptions
|
20 | * @param {number} [maxRedirects = RedirectHandlerOptions.DEFAULT_MAX_REDIRECTS] - The max redirects value
|
21 | * @param {ShouldRedirect} [shouldRedirect = RedirectHandlerOptions.DEFAULT_SHOULD_RETRY] - The should redirect callback
|
22 | * @returns An instance of RedirectHandlerOptions
|
23 | */
|
24 | function RedirectHandlerOptions(maxRedirects, shouldRedirect) {
|
25 | if (maxRedirects === void 0) { maxRedirects = RedirectHandlerOptions.DEFAULT_MAX_REDIRECTS; }
|
26 | if (shouldRedirect === void 0) { shouldRedirect = RedirectHandlerOptions.defaultShouldRedirect; }
|
27 | if (maxRedirects > RedirectHandlerOptions.MAX_MAX_REDIRECTS) {
|
28 | var error = new Error("MaxRedirects should not be more than ".concat(RedirectHandlerOptions.MAX_MAX_REDIRECTS));
|
29 | error.name = "MaxLimitExceeded";
|
30 | throw error;
|
31 | }
|
32 | if (maxRedirects < 0) {
|
33 | var error = new Error("MaxRedirects should not be negative");
|
34 | error.name = "MinExpectationNotMet";
|
35 | throw error;
|
36 | }
|
37 | this.maxRedirects = maxRedirects;
|
38 | this.shouldRedirect = shouldRedirect;
|
39 | }
|
40 | /**
|
41 | * @private
|
42 | * @static
|
43 | * A member holding default max redirects value
|
44 | */
|
45 | RedirectHandlerOptions.DEFAULT_MAX_REDIRECTS = 5;
|
46 | /**
|
47 | * @private
|
48 | * @static
|
49 | * A member holding maximum max redirects value
|
50 | */
|
51 | RedirectHandlerOptions.MAX_MAX_REDIRECTS = 20;
|
52 | /**
|
53 | * @private
|
54 | * A member holding default shouldRedirect callback
|
55 | */
|
56 | RedirectHandlerOptions.defaultShouldRedirect = function () { return true; };
|
57 | return RedirectHandlerOptions;
|
58 | }());
|
59 | exports.RedirectHandlerOptions = RedirectHandlerOptions;
|
60 | //# sourceMappingURL=RedirectHandlerOptions.js.map |
\ | No newline at end of file |