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,15 @@ var loginStageCounter = 0;
3636const maxRunningWorkflows = 20 ;
3737
3838
39+ function generateUUID ( )
40+ {
41+ //UI-93290e40-3e26-42a9-8bc3-b50c32b7115b
42+ var hexstring = crypto . randomBytes ( 16 ) . toString ( "hex" ) ;
43+ var guidstring = "UI-" + hexstring . substring ( 0 , 8 ) + "-" + hexstring . substring ( 8 , 12 ) + "-" + hexstring . substring ( 12 , 16 ) + "-" + hexstring . substring ( 16 , 20 ) + "-" + hexstring . substring ( 20 ) ;
44+ //var uuid = "UI-" + crypto;
45+ return guidstring ;
46+ }
47+
3948function debug ( message ) {
4049 dbg . message ( "<EXPERIMENTAL> " + message , 4 ) ;
4150}
@@ -206,7 +215,9 @@ function setHeaders()
206215 var headers = [
207216 { name :"authtoken" , value :authtoken } ,
208217 { name :"accept" , value :"application/json" } ,
209- { name :"x-csrf-token" , value :csrf } ,
218+ //{name:"x-csrf-token",value:csrf},
219+ { name :"X-Requested-With" , value :"XMLHttpRequest" } ,
220+ { name :"X-Request-ID" , value :generateUUID ( ) } ,
210221 ] ;
211222 return headers ;
212223}
@@ -333,7 +344,7 @@ function processRunningResponse(url,err,body,res){
333344 }
334345 else
335346 {
336- dbg . message ( "Failed to get Running Workflows" , 1 ) ;
347+ dbg . message ( "DAVE Failed to get Running Workflows" , 1 ) ;
337348 dbg . message ( err , 1 ) ;
338349 process . exit ( 99 ) ;
339350 }
@@ -393,8 +404,8 @@ function processRunningResponse(url,err,body,res){
393404 else
394405 {
395406 dbg . message ( "Failed to get Running Workflows" , 1 )
396- dbg . message ( err , 4 )
397- dbg . message ( body , 4 )
407+ if ( body != null ) dbg . message ( JSON . stringify ( body ) , 1 ) ;
408+ if ( err != null ) dbg . message ( JSON . stringify ( err ) , 2 ) ;
398409 process . exit ( 99 ) ;
399410 }
400411}
0 commit comments