Skip to content

Commit

Permalink
feat: add tls.servername option for fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
mrkurt committed Apr 10, 2019
1 parent cb1b216 commit ab9b935
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion packages/core/src/bridge/fetch/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/bridge/fetch/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export interface RequestInit {
readTimeout?: number
headers?: Record<string, string>
certificate?: Certificate
tls?: {
servername?: string
}
}

export type FetchBody = string | number | ArrayBuffer | Buffer | null
Expand Down
6 changes: 5 additions & 1 deletion packages/v8env/src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export interface FlyRequestInit extends RequestInit {
pfx?: string | Buffer | Array<string | Buffer>
passphrase?: string
}
tls?: {
servername?: string
}
}

/**
Expand All @@ -40,7 +43,8 @@ export function fetch(req: RequestInfo, init?: FlyRequestInit): Promise<Response
headers: (req.headers && req.headers.toJSON()) || {},
timeout: init && init.timeout,
readTimeout: (init && init.readTimeout) || 30 * 1000,
certificate: init && init.certificate
certificate: init && init.certificate,
tls: init && init.tls
}
if (!req.bodySource) {
bridge.dispatch("fetch", url, init, null, fetchCb)
Expand Down

0 comments on commit ab9b935

Please sign in to comment.