From f180d0580457e1e9bd502293df327dfe138dd422 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Wed, 12 Aug 2020 12:41:00 +0530 Subject: remove excessive namespacing, format --- .../src/browserHttpLib.ts | 47 +++++++++++++++++----- 1 file changed, 36 insertions(+), 11 deletions(-) (limited to 'packages/taler-wallet-webextension/src/browserHttpLib.ts') diff --git a/packages/taler-wallet-webextension/src/browserHttpLib.ts b/packages/taler-wallet-webextension/src/browserHttpLib.ts index 42c0c4f00..c568862d9 100644 --- a/packages/taler-wallet-webextension/src/browserHttpLib.ts +++ b/packages/taler-wallet-webextension/src/browserHttpLib.ts @@ -1,5 +1,30 @@ +/* + This file is part of GNU Taler + (C) 2020 Taler Systems S.A. -import { httpLib, OperationFailedError, Logger } from "taler-wallet-core"; + GNU Taler is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with + GNU Taler; see the file COPYING. If not, see + */ + +/** + * Imports. + */ +import { + OperationFailedError, + Logger, + HttpRequestLibrary, + HttpRequestOptions, + HttpResponse, + Headers, +} from "taler-wallet-core"; import { TalerErrorCode } from "taler-wallet-core/lib/TalerErrorCode"; const logger = new Logger("browserHttpLib"); @@ -8,14 +33,14 @@ const logger = new Logger("browserHttpLib"); * An implementation of the [[HttpRequestLibrary]] using the * browser's XMLHttpRequest. */ -export class BrowserHttpLib implements httpLib.HttpRequestLibrary { +export class BrowserHttpLib implements HttpRequestLibrary { private req( method: string, url: string, requestBody?: any, - options?: httpLib.HttpRequestOptions, - ): Promise { - return new Promise((resolve, reject) => { + options?: HttpRequestOptions, + ): Promise { + return new Promise((resolve, reject) => { const myRequest = new XMLHttpRequest(); myRequest.open(method, url); if (options?.headers) { @@ -87,7 +112,7 @@ export class BrowserHttpLib implements httpLib.HttpRequestLibrary { const arr = headers.trim().split(/[\r\n]+/); // Create a map of header names to values - const headerMap: httpLib.Headers = new httpLib.Headers(); + const headerMap: Headers = new Headers(); arr.forEach(function (line) { const parts = line.split(": "); const headerName = parts.shift(); @@ -98,7 +123,7 @@ export class BrowserHttpLib implements httpLib.HttpRequestLibrary { const value = parts.join(": "); headerMap.set(headerName, value); }); - const resp: httpLib.HttpResponse = { + const resp: HttpResponse = { requestUrl: url, status: myRequest.status, headers: headerMap, @@ -112,19 +137,19 @@ export class BrowserHttpLib implements httpLib.HttpRequestLibrary { }); } - get(url: string, opt?: httpLib.HttpRequestOptions): Promise { + get(url: string, opt?: HttpRequestOptions): Promise { return this.req("GET", url, undefined, opt); } postJson( url: string, body: unknown, - opt?: httpLib.HttpRequestOptions, - ): Promise { + opt?: HttpRequestOptions, + ): Promise { return this.req("POST", url, JSON.stringify(body), opt); } stop(): void { // Nothing to do } -} \ No newline at end of file +} -- cgit v1.2.3