1111
1212const request = require ( "request" ) ;
1313const rest = require ( "./rest.js" ) ;
14-
14+ const crypto = require ( 'crypto' ) ;
1515
1616
1717var domainName , username , password , timeout ;
@@ -36,6 +36,12 @@ var loginStageCounter = 0;
3636const maxRunningWorkflows = 20 ;
3737
3838
39+ function generateUUID ( ) {
40+ var hexstring = crypto . randomBytes ( 16 ) . toString ( "hex" ) ;
41+ var guidstring = "UI-" + hexstring . substring ( 0 , 8 ) + "-" + hexstring . substring ( 8 , 12 ) + "-" + hexstring . substring ( 12 , 16 ) + "-" + hexstring . substring ( 16 , 20 ) + "-" + hexstring . substring ( 20 ) ;
42+ return guidstring ;
43+ }
44+
3945function debug ( message ) {
4046 dbg . message ( "<EXPERIMENTAL> " + message , 4 ) ;
4147}
@@ -206,7 +212,9 @@ function setHeaders()
206212 var headers = [
207213 { name :"authtoken" , value :authtoken } ,
208214 { name :"accept" , value :"application/json" } ,
209- { name :"x-csrf-token" , value :csrf } ,
215+ //{name:"x-csrf-token",value:csrf},
216+ { name :"X-Requested-With" , value :"XMLHttpRequest" } ,
217+ { name :"X-Request-ID" , value :generateUUID ( ) } ,
210218 ] ;
211219 return headers ;
212220}
@@ -362,7 +370,8 @@ function processListResponse(url,err,body,res){
362370 else
363371 {
364372 dbg . message ( "Failed to get Running Workflows" , 1 )
365- dbg . message ( err , 1 ) ;
373+ if ( body != null ) dbg . message ( JSON . stringify ( body ) , 1 ) ;
374+ if ( err != null ) dbg . message ( JSON . stringify ( err ) , 2 ) ;
366375 process . exit ( 99 ) ;
367376 }
368377}
@@ -393,8 +402,8 @@ function processRunningResponse(url,err,body,res){
393402 else
394403 {
395404 dbg . message ( "Failed to get Running Workflows" , 1 )
396- dbg . message ( err , 4 )
397- dbg . message ( body , 4 )
405+ if ( body != null ) dbg . message ( JSON . stringify ( body ) , 1 ) ;
406+ if ( err != null ) dbg . message ( JSON . stringify ( err ) , 2 ) ;
398407 process . exit ( 99 ) ;
399408 }
400409}
0 commit comments