From ab9b93591d26e0da58739bd92a4b2b9b1c3cb42a Mon Sep 17 00:00:00 2001 From: Kurt Date: Wed, 10 Apr 2019 09:56:40 -0500 Subject: [PATCH] feat: add tls.servername option for fetch --- packages/core/src/bridge/fetch/http.ts | 6 +++++- packages/core/src/bridge/fetch/types.ts | 3 +++ packages/v8env/src/fetch.ts | 6 +++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/packages/core/src/bridge/fetch/http.ts b/packages/core/src/bridge/fetch/http.ts index 123ecfe0..963e621e 100644 --- a/packages/core/src/bridge/fetch/http.ts +++ b/packages/core/src/bridge/fetch/http.ts @@ -51,7 +51,11 @@ export function handleRequest( } if (httpFn === https.request) { - reqOptions.servername = reqOptions.hostname + if (init.tls && init.tls.servername) { + reqOptions.servername = init.tls.servername + } else { + reqOptions.servername = reqOptions.hostname + } } req = httpFn(reqOptions) diff --git a/packages/core/src/bridge/fetch/types.ts b/packages/core/src/bridge/fetch/types.ts index 262201bc..5cb4cd53 100644 --- a/packages/core/src/bridge/fetch/types.ts +++ b/packages/core/src/bridge/fetch/types.ts @@ -8,6 +8,9 @@ export interface RequestInit { readTimeout?: number headers?: Record certificate?: Certificate + tls?: { + servername?: string + } } export type FetchBody = string | number | ArrayBuffer | Buffer | null diff --git a/packages/v8env/src/fetch.ts b/packages/v8env/src/fetch.ts index f76f9b35..a14dd36a 100644 --- a/packages/v8env/src/fetch.ts +++ b/packages/v8env/src/fetch.ts @@ -16,6 +16,9 @@ export interface FlyRequestInit extends RequestInit { pfx?: string | Buffer | Array passphrase?: string } + tls?: { + servername?: string + } } /** @@ -40,7 +43,8 @@ export function fetch(req: RequestInfo, init?: FlyRequestInit): Promise