Skip to content

Commit 80d27f7

Browse files
authored
fix: res headers maybe IncomingHttpHeaders (#9)
1 parent c607266 commit 80d27f7

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

index.test-d.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import { Writable, Readable } from 'node:stream';
2+
import { IncomingHttpHeaders } from 'node:http';
13
import { expectType } from 'tsd';
2-
import { Writable, Readable } from 'stream';
34
import {
45
GetObjectOptions,
56
IObjectSimple,
@@ -36,7 +37,7 @@ class SimpleClient implements IObjectSimple {
3637
status: 200,
3738
res: {
3839
status: 200,
39-
headers: {},
40+
headers: {} as IncomingHttpHeaders,
4041
size: 0,
4142
rt: 0,
4243
},
@@ -78,7 +79,8 @@ expectType<Promise<GetObjectResult>>(simpleClient.get('foo'));
7879
const result = await simpleClient.getStream('foo');
7980
expectType<Readable>(result.stream);
8081
expectType<number>(result.res.status);
81-
expectType<string>(result.res.headers.etag);
82+
expectType<string | undefined>(result.res.headers.etag);
83+
expectType<string | string[] | undefined>(result.res.headers['set-cookie']);
8284

8385
let listResult = await simpleClient.list({ prefix: 'foo' });
8486
expectType<number>(listResult.objects.length);

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Readable, Writable } from 'node:stream';
2+
import { IncomingHttpHeaders } from 'node:http';
23

34
export type StorageType = 'Standard' | 'IA' | 'Archive';
45

@@ -33,7 +34,7 @@ export interface NormalSuccessResponse {
3334
/** response status */
3435
status: number;
3536
/** response headers */
36-
headers: Record<string, string>;
37+
headers: Record<string, string> | IncomingHttpHeaders;
3738
/** response size */
3839
size: number;
3940
/** request total use time (ms) */

0 commit comments

Comments
 (0)