From 4c4ca4536416a715d41126c0910de1ae5541d817 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Sun, 17 Sep 2023 21:36:18 +0800 Subject: [PATCH] fix: res headers maybe IncomingHttpHeaders --- index.test-d.ts | 8 +++++--- src/index.ts | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/index.test-d.ts b/index.test-d.ts index ae2b5dd..274f757 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -1,5 +1,6 @@ +import { Writable, Readable } from 'node:stream'; +import { IncomingHttpHeaders } from 'node:http'; import { expectType } from 'tsd'; -import { Writable, Readable } from 'stream'; import { GetObjectOptions, IObjectSimple, @@ -36,7 +37,7 @@ class SimpleClient implements IObjectSimple { status: 200, res: { status: 200, - headers: {}, + headers: {} as IncomingHttpHeaders, size: 0, rt: 0, }, @@ -78,7 +79,8 @@ expectType>(simpleClient.get('foo')); const result = await simpleClient.getStream('foo'); expectType(result.stream); expectType(result.res.status); -expectType(result.res.headers.etag); +expectType(result.res.headers.etag); +expectType(result.res.headers['set-cookie']); let listResult = await simpleClient.list({ prefix: 'foo' }); expectType(listResult.objects.length); diff --git a/src/index.ts b/src/index.ts index 417d900..5d4186f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ import { Readable, Writable } from 'node:stream'; +import { IncomingHttpHeaders } from 'node:http'; export type StorageType = 'Standard' | 'IA' | 'Archive'; @@ -33,7 +34,7 @@ export interface NormalSuccessResponse { /** response status */ status: number; /** response headers */ - headers: Record; + headers: Record | IncomingHttpHeaders; /** response size */ size: number; /** request total use time (ms) */