feat(got): add got timoutoptions

workaround for timeout

fix test
This commit is contained in:
Dominique
2018-03-14 15:32:12 +01:00
parent ef640e2b2b
commit 3808fe6627
2 changed files with 20 additions and 2 deletions

View File

@@ -52,6 +52,20 @@ got('todomvc.com', {
encoding: 'utf8',
hostname: 'todomvc'
}).then(response => str = response.body);
got('todomvc.com', {
form: true,
body: [{}],
encoding: 'utf8',
hostname: 'todomvc',
timeout: 2000
}).then(response => str = response.body);
got('todomvc.com', {
form: true,
body: [{}],
encoding: 'utf8',
hostname: 'todomvc',
timeout: {connect: 20, request: 20, socket: 20}
}).then(response => str = response.body);
// following must lead to type checking error: got('todomvc.com', {form: true, body: ''}).then(response => str = response.body);
got('todomvc.com', {encoding: null, hostname: 'todomvc'}).then(response => buf = response.body);

View File

@@ -98,7 +98,11 @@ declare namespace got {
json?: boolean;
}
type GotOptions<E extends string | null> = http.RequestOptions & {
interface TimoutRequestOptions extends http.RequestOptions {
timeout?: any;
}
interface GotOptions<E extends string | null> extends TimoutRequestOptions {
encoding?: E;
query?: string | object;
timeout?: number | TimeoutOptions;
@@ -106,7 +110,7 @@ declare namespace got {
followRedirect?: boolean;
decompress?: boolean;
useElectronNet?: boolean;
};
}
interface TimeoutOptions {
connect?: number;