mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-12-06 17:27:59 +00:00
feat: allow customized connection headers (#2036)
Co-authored-by: Elliot Lee <github.public@intelliot.com>
This commit is contained in:
@@ -36,6 +36,7 @@ interface ConnectionOptions {
|
||||
// request timeout
|
||||
timeout: number
|
||||
connectionTimeout: number
|
||||
headers?: { [key: string]: string }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,9 +115,15 @@ function createWebSocket(
|
||||
): WebSocket | null {
|
||||
const options: WebSocket.ClientOptions = {}
|
||||
options.agent = getAgent(url, config)
|
||||
if (config.headers) {
|
||||
options.headers = config.headers
|
||||
}
|
||||
if (config.authorization != null) {
|
||||
const base64 = Buffer.from(config.authorization).toString('base64')
|
||||
options.headers = { Authorization: `Basic ${base64}` }
|
||||
options.headers = {
|
||||
...options.headers,
|
||||
Authorization: `Basic ${base64}`,
|
||||
}
|
||||
}
|
||||
const optionsOverrides = _.omitBy(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user