Skip to content

Commit

Permalink
fix: res headers maybe IncomingHttpHeaders (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Sep 17, 2023
1 parent c607266 commit 80d27f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions index.test-d.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -36,7 +37,7 @@ class SimpleClient implements IObjectSimple {
status: 200,
res: {
status: 200,
headers: {},
headers: {} as IncomingHttpHeaders,
size: 0,
rt: 0,
},
Expand Down Expand Up @@ -78,7 +79,8 @@ expectType<Promise<GetObjectResult>>(simpleClient.get('foo'));
const result = await simpleClient.getStream('foo');
expectType<Readable>(result.stream);
expectType<number>(result.res.status);
expectType<string>(result.res.headers.etag);
expectType<string | undefined>(result.res.headers.etag);
expectType<string | string[] | undefined>(result.res.headers['set-cookie']);

let listResult = await simpleClient.list({ prefix: 'foo' });
expectType<number>(listResult.objects.length);
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Readable, Writable } from 'node:stream';
import { IncomingHttpHeaders } from 'node:http';

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

Expand Down Expand Up @@ -33,7 +34,7 @@ export interface NormalSuccessResponse {
/** response status */
status: number;
/** response headers */
headers: Record<string, string>;
headers: Record<string, string> | IncomingHttpHeaders;
/** response size */
size: number;
/** request total use time (ms) */
Expand Down

0 comments on commit 80d27f7

Please sign in to comment.