@@ -7,6 +7,7 @@ var timeoutReq = require('timed-out');
77var http = require ( 'http' ) ;
88var https = require ( 'https' ) ;
99var tunnel = require ( 'tunnel-agent' ) ;
10+ var Buffer = require ( "safe-buffer" ) . Buffer ;
1011
1112var agentOptions = {
1213 keepAlive : true ,
@@ -41,6 +42,11 @@ HTTPTransport.prototype.send = function (client, message, headers, eventId, cb)
4142 if ( client . dsn . protocol === 'http' ) {
4243 options . path = 'http://' + client . dsn . host + ':' + client . dsn . port + client . dsn . path + 'api/' + client . dsn . project_id + '/store/' ;
4344 delete options . hostname ; // only 'host' should be set when using proxy
45+
46+ if ( this . options . proxyAuth ) {
47+ // might be able to use httpOverHttp agent
48+ options . headers [ "Proxy-Authorization" ] = "Basic " + Buffer . from ( this . options . proxyAuth ) . toString ( "base64" ) ;
49+ }
4450 } else {
4551 this . options . agent . proxyOptions . headers = {
4652 'Content-Type' : 'application/octet-stream' ,
@@ -117,6 +123,10 @@ function HTTPProxyTransport(options) {
117123 this . agent = httpAgent ;
118124 this . options . host = options . proxyHost ;
119125 this . options . port = options . proxyPort ;
126+
127+ if ( options . proxyUser && options . proxyPassword ) {
128+ this . options . proxyAuth = options . proxyUser + ':' + options . proxyPassword ;
129+ }
120130}
121131
122132function HTTPSProxyTransport ( options ) {
@@ -127,7 +137,10 @@ function HTTPSProxyTransport(options) {
127137 proxy : {
128138 host : options . proxyHost ,
129139 port : options . proxyPort ,
130- proxyAuth : null // TODO: Add ability to specify creds/auth
140+ proxyAuth :
141+ options . proxyUser && options . proxyPassword
142+ ? options . proxyUser + ':' + options . proxyPassword
143+ : null
131144 } ,
132145 keepAlive : agentOptions . keepAlive ,
133146 maxSockets : agentOptions . maxSockets
0 commit comments