Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: res headers maybe IncomingHttpHeaders #9

Merged
merged 1 commit into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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