nodemailer: fetch returns Writable with extra properties

This commit is contained in:
Piotr Roszatycki
2018-03-06 10:56:04 +01:00
parent 716c8476f3
commit 2100880c79
2 changed files with 12 additions and 2 deletions

View File

@@ -4,12 +4,18 @@ type ms = number;
import _Cookies = require('./cookies');
import * as http from 'http';
import { Writable } from 'stream';
import * as tls from 'tls';
declare namespace fetch {
type Cookies = _Cookies;
interface WritableResponse extends Writable {
statusCode: number;
headers: http.IncomingHttpHeaders;
}
interface Options {
fetchRes?: Writable;
cookies?: Cookies;
@@ -27,6 +33,6 @@ declare namespace fetch {
}
}
declare function fetch(url: string, options?: fetch.Options): Writable;
declare function fetch(url: string, options?: fetch.Options): fetch.WritableResponse;
export = fetch;

View File

@@ -1090,7 +1090,11 @@ function base64_test() {
// fetch
function fetch_test() {
fetch('http://localhost/');
const stream = fetch('http://localhost/');
const statusCode: number = stream.statusCode;
const headers = stream.headers;
const contentType: string | undefined = headers['content-type'];
fetch('http://localhost:/', {
allowErrorResponse: true,