@@ -20,7 +20,7 @@ var RequestLib = {
2020 * @param {http.IncomingMessage } clientRequest
2121 * @param {Number } retries
2222 */
23- _makeRequest : function ( schemeObj , params , clientRequest , requestType , retries ) {
23+ _makeRequest : function ( schemeObj , params , clientRequest , serverType , retries ) {
2424 return new Promise ( function ( resolve , reject ) {
2525 var requestOptions = Object . assign ( { } , params . furtherRequestOptions ) ;
2626 requestOptions . agent = RdGlobalConfig . SCHEME === 'http' ? httpKeepAliveAgent : httpsKeepAliveAgent ;
@@ -45,12 +45,12 @@ var RequestLib = {
4545 response . on ( 'data' , function ( chunk ) {
4646 responseToSend . data . push ( chunk ) ;
4747 } ) ;
48-
48+
4949 response . on ( 'end' , function ( ) {
5050 responseToSend . data = Buffer . concat ( responseToSend . data ) . toString ( ) ;
5151 resolve ( responseToSend ) ;
5252 } ) ;
53-
53+
5454 response . on ( 'error' , function ( err ) {
5555 reject ( {
5656 message : err ,
@@ -61,9 +61,9 @@ var RequestLib = {
6161
6262 // Log the request that will be initiated on behalf of the client
6363 request . on ( 'finish' , function ( ) {
64- var url = RdGlobalConfig . SCHEME + "://" + requestOptions . host + requestOptions . path ;
64+ var requestUrl = RdGlobalConfig . SCHEME + "://" + requestOptions . host + requestOptions . path ;
6565 RdGlobalConfig . reqLogger . info ( constants . TOPICS . TOOL_REQUEST_WITH_RETRIES + retries ,
66- clientRequest . method + ' ' + url , false , Object . assign ( { } , params . furtherRequestOptions , {
66+ clientRequest . method + ' ' + requestUrl , false , Object . assign ( { } , params . furtherRequestOptions , {
6767 data : Buffer . concat ( params . request . data ) . toString ( )
6868 } ) ,
6969 clientRequest . id ) ;
@@ -98,18 +98,18 @@ var RequestLib = {
9898 } ) ;
9999 }
100100 } ) ;
101-
101+
102102 clientRequest . on ( 'error' , function ( err ) {
103103 request . end ( ) ;
104104 reject ( {
105105 message : err ,
106106 customTopic : constants . TOPICS . CLIENT_REQUEST_WITH_RETRIES + retries
107107 } ) ;
108108 } ) ;
109-
109+
110110 clientRequest . on ( 'end' , function ( ) {
111- var url = requestType === constants . REQUEST_TYPES . PROXY ? clientRequest . url : "http://" + clientRequest . headers . host + clientRequest . url ;
112- RdGlobalConfig . reqLogger . info ( constants . TOPICS . CLIENT_REQUEST_END , params . request . method + ' ' + url , false , {
111+ var requestUrl = serverType === constants . SERVER_TYPES . PROXY ? clientRequest . url : "http://" + clientRequest . headers . host + requestOptions . path ;
112+ RdGlobalConfig . reqLogger . info ( constants . TOPICS . CLIENT_REQUEST_END , params . request . method + ' ' + requestUrl , false , {
113113 data : Buffer . concat ( params . request . data ) . toString ( )
114114 } ,
115115 clientRequest . id ) ;
@@ -128,10 +128,10 @@ var RequestLib = {
128128 * @param {http.IncomingMessage } clientRequest
129129 * @param {Number } retries
130130 */
131- call : function ( params , clientRequest , requestType , retries ) {
131+ call : function ( params , clientRequest , serverType , retries ) {
132132 retries = ( typeof retries === 'number' ) ? Math . min ( constants . MAX_RETRIES , Math . max ( retries , 0 ) ) : constants . MAX_RETRIES ;
133133 var schemeObj = RdGlobalConfig . SCHEME === "http" ? http : https ;
134- return RequestLib . _makeRequest ( schemeObj , params , clientRequest , requestType , retries )
134+ return RequestLib . _makeRequest ( schemeObj , params , clientRequest , serverType , retries )
135135 . catch ( function ( err ) {
136136 var errTopic = err . customTopic || constants . TOPICS . UNEXPECTED_ERROR ;
137137 // Collect Network & Connectivity Logs whenever a request fails
@@ -147,7 +147,7 @@ var RequestLib = {
147147
148148 return Utils . delay ( RdGlobalConfig . RETRY_DELAY )
149149 . then ( function ( ) {
150- return RequestLib . call ( params , clientRequest , requestType , retries - 1 , false ) ;
150+ return RequestLib . call ( params , clientRequest , serverType , retries - 1 , false ) ;
151151 } ) ;
152152 } else {
153153 throw err ;
0 commit comments