diff options
author | Florian Dold <florian@dold.me> | 2023-12-04 21:48:22 +0100 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2023-12-04 21:48:22 +0100 |
commit | c00b523c662566e993474f6c3dc4c1f90b860e34 (patch) | |
tree | 51d2d48dbc993442061b4722ff44eeab208d0177 | |
parent | c93d53d6473934f1d6082a25e2fe26b90c55bb91 (diff) | |
download | wallet-core-c00b523c662566e993474f6c3dc4c1f90b860e34.tar.xz |
util: return headers in qtart http client
-rw-r--r-- | packages/taler-util/src/http-impl.qtart.ts | 18 | ||||
-rw-r--r-- | packages/taler-util/src/qtart.ts | 1 |
2 files changed, 17 insertions, 2 deletions
diff --git a/packages/taler-util/src/http-impl.qtart.ts b/packages/taler-util/src/http-impl.qtart.ts index fb642ac89..d4ec26bd0 100644 --- a/packages/taler-util/src/http-impl.qtart.ts +++ b/packages/taler-util/src/http-impl.qtart.ts @@ -97,10 +97,24 @@ export class HttpLibImpl implements HttpRequestLibrary { data, headers: headersList, }); + + const headers: Headers = new Headers(); + + if (res.headers) { + for (const headerStr of res.headers) { + const splitPos = headerStr.indexOf(":"); + if (splitPos < 0) { + continue; + } + const headerName = headerStr.slice(0, splitPos).trim().toLowerCase(); + const headerValue = headerStr.slice(splitPos + 1).trim(); + headers.set(headerName, headerValue); + } + } + return { requestMethod: method, - // FIXME: We don't return headers! - headers: new Headers(), + headers, async bytes() { return res.data; }, diff --git a/packages/taler-util/src/qtart.ts b/packages/taler-util/src/qtart.ts index 327a51e7d..e298a157c 100644 --- a/packages/taler-util/src/qtart.ts +++ b/packages/taler-util/src/qtart.ts @@ -6,6 +6,7 @@ import * as _qjsStdImp from "std"; export interface QjsHttpResp { status: number; data: ArrayBuffer; + headers?: string[]; } export interface QjsHttpOptions { |