UNPKG

2.26 kBTypeScriptView Raw
1/**
2 * -------------------------------------------------------------------------------------------
3 * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
4 * See License in the project root for license information.
5 * -------------------------------------------------------------------------------------------
6 */
7/**
8 * @module HTTPClientFactory
9 */
10import { HTTPClient } from "./HTTPClient";
11import { AuthenticationProvider } from "./IAuthenticationProvider";
12import { Middleware } from "./middleware/IMiddleware";
13/**
14 * @class
15 * Class representing HTTPClientFactory
16 */
17export declare class HTTPClientFactory {
18 /**
19 * @public
20 * @static
21 * Creates HTTPClient with default middleware chain
22 * @param {AuthenticationProvider} authProvider - The authentication provider instance
23 * @returns A HTTPClient instance
24 *
25 * NOTE: These are the things that we need to remember while doing modifications in the below default pipeline.
26 * * HTTPMessageHandler should be the last one in the middleware pipeline, because this makes the actual network call of the request
27 * * TelemetryHandler should be the one prior to the last middleware in the chain, because this is the one which actually collects and appends the usage flag and placing this handler * before making the actual network call ensures that the usage of all features are recorded in the flag.
28 * * The best place for AuthenticationHandler is in the starting of the pipeline, because every other handler might have to work for multiple times for a request but the auth token for
29 * them will remain same. For example, Retry and Redirect handlers might be working multiple times for a request based on the response but their auth token would remain same.
30 */
31 static createWithAuthenticationProvider(authProvider: AuthenticationProvider): HTTPClient;
32 /**
33 * @public
34 * @static
35 * Creates a middleware chain with the given one
36 * @property {...Middleware} middleware - The first middleware of the middleware chain or a sequence of all the Middleware handlers
37 * @returns A HTTPClient instance
38 */
39 static createWithMiddleware(...middleware: Middleware[]): HTTPClient;
40}