| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- // Copyright (c) .NET Foundation. All rights reserved.
- // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- import { AbortError } from "./Errors";
- import { HttpClient } from "./HttpClient";
- import { NodeHttpClient } from "./NodeHttpClient";
- import { XhrHttpClient } from "./XhrHttpClient";
- /** Default implementation of {@link @aspnet/signalr.HttpClient}. */
- var DefaultHttpClient = /** @class */ (function (_super) {
- __extends(DefaultHttpClient, _super);
- /** Creates a new instance of the {@link @aspnet/signalr.DefaultHttpClient}, using the provided {@link @aspnet/signalr.ILogger} to log messages. */
- function DefaultHttpClient(logger) {
- var _this = _super.call(this) || this;
- if (typeof XMLHttpRequest !== "undefined") {
- _this.httpClient = new XhrHttpClient(logger);
- }
- else {
- _this.httpClient = new NodeHttpClient(logger);
- }
- return _this;
- }
- /** @inheritDoc */
- DefaultHttpClient.prototype.send = function (request) {
- // Check that abort was not signaled before calling send
- if (request.abortSignal && request.abortSignal.aborted) {
- return Promise.reject(new AbortError());
- }
- if (!request.method) {
- return Promise.reject(new Error("No method defined."));
- }
- if (!request.url) {
- return Promise.reject(new Error("No url defined."));
- }
- return this.httpClient.send(request);
- };
- DefaultHttpClient.prototype.getCookieString = function (url) {
- return this.httpClient.getCookieString(url);
- };
- return DefaultHttpClient;
- }(HttpClient));
- export { DefaultHttpClient };
- //# sourceMappingURL=DefaultHttpClient.js.map
|