Skip to content

Commit 1e5bbc6

Browse files
olzzonJulusian
authored andcommitted
feat: support for http header in packagemanager
1 parent 6b02621 commit 1e5bbc6

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

packages/server-core-integration/src/lib/coreConnection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export class CoreConnection<
126126
}
127127
})
128128

129-
const ddpOptions = ddpOptions0 || {
129+
const ddpOptions: DDPConnectorOptions = ddpOptions0 || {
130130
host: '127.0.0.1',
131131
port: 3000,
132132
}

packages/server-core-integration/src/lib/ddpClient.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export interface TLSOpts {
3434
export interface DDPConnectorOptions {
3535
host: string
3636
port: number
37+
headers?: { [header: string]: string }
3738
path?: string
3839
ssl?: boolean
3940
debug?: boolean
@@ -343,6 +344,10 @@ export class DDPClient extends EventEmitter<DDPClientEvents> {
343344
public get port(): number {
344345
return this.portInt
345346
}
347+
private headersInt: { [header: string]: string } = {}
348+
public get headers(): { [header: string]: string } {
349+
return this.headersInt
350+
}
346351
private pathInt?: string
347352
public get path(): string | undefined {
348353
return this.pathInt
@@ -410,6 +415,7 @@ export class DDPClient extends EventEmitter<DDPClientEvents> {
410415
// console.log(opts)
411416
this.hostInt = opts.host || '127.0.0.1'
412417
this.portInt = opts.port || 3000
418+
this.headersInt = opts.headers || {}
413419
this.pathInt = opts.path
414420
this.sslInt = opts.ssl || this.port === 443
415421
this.tlsOpts = opts.tlsOpts || {}
@@ -722,6 +728,7 @@ export class DDPClient extends EventEmitter<DDPClientEvents> {
722728

723729
try {
724730
const response = await got(url, {
731+
headers: this.headers,
725732
https: {
726733
certificateAuthority: this.tlsOpts.ca,
727734
key: this.tlsOpts.key,
@@ -762,7 +769,7 @@ export class DDPClient extends EventEmitter<DDPClientEvents> {
762769

763770
private makeWebSocketConnection(url: string): void {
764771
// console.log('About to create WebSocket client')
765-
this.socket = new WebSocket.Client(url, null, { tls: this.tlsOpts })
772+
this.socket = new WebSocket.Client(url, null, { tls: this.tlsOpts, headers: this.headers })
766773

767774
this.socket.on('open', () => {
768775
// just go ahead and open the connection on connect

packages/server-core-integration/src/lib/ddpConnector.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export class DDPConnector extends EventEmitter<DDPConnectorEvents> {
3131
const o: DDPConnectorOptions = {
3232
host: this._options.host,
3333
port: this._options.port,
34+
headers: this._options.headers,
3435
path: this._options.path || '',
3536
ssl: this._options.ssl || false,
3637
tlsOpts: this._options.tlsOpts || {},

0 commit comments

Comments
 (0)