@@ -348,9 +348,9 @@ class Arazzo extends Document {
348348 } else {
349349 this . logger . verbose ( "Using fetch call" ) ;
350350
351- this . logger . verbose ( `url: ${ url } ` ) ;
352- this . logger . verbose ( `method: ${ options . method } ` ) ;
353- this . logger . verbose ( "headers:" ) ;
351+ this . logger . verbose ( `request url: ${ url } ` ) ;
352+ this . logger . verbose ( `request method: ${ options . method } ` ) ;
353+ this . logger . verbose ( "request headers:" ) ;
354354 for ( const [ key , value ] of options . headers . entries ( ) ) {
355355 this . logger . verbose ( `${ key } : ${ value } ` ) ;
356356 }
@@ -360,6 +360,12 @@ class Arazzo extends Document {
360360 response = await fetch ( url , options ) ;
361361 }
362362
363+ this . logger . verbose ( `received StatusCode: ${ response . status } ` ) ;
364+ this . logger . verbose ( `received headers:` ) ;
365+ for ( const [ key , value ] of response . headers . entries ( ) ) {
366+ this . logger . verbose ( `${ key } : ${ value } ` ) ;
367+ }
368+
363369 if ( response . headers . has ( "retry-after" ) ) {
364370 const retryAfter = parseRetryAfter ( response . headers . get ( "retry-after" ) ) ;
365371 if ( retryAfter !== null ) {
@@ -504,32 +510,48 @@ class Arazzo extends Document {
504510 * @param {* } response
505511 */
506512 async dealWithResponse ( response ) {
513+ if (
514+ response . headers . has ( "Content-Type" ) &&
515+ response . headers . get ( "Content-Type" ) === "application/json"
516+ ) {
517+ const json = await response ?. json ( ) . catch ( ( err ) => {
518+ this . logger . error (
519+ `Error trying to resolve ${ this . step . stepId } outputs` ,
520+ ) ;
521+ throw new Error ( err ) ;
522+ } ) ;
523+
524+ this . expression . addToContext ( "response.body" , json ) ;
525+ } else {
526+ const body = await response . body ;
527+
528+ this . expression . addToContext ( "response.body" , body ) ;
529+ }
530+
507531 this . doNotProcessStep = false ;
508532 this . alreadyProcessingOnFailure = false ;
509533
510534 if ( this . step . successCriteria ) {
511- if ( this . step . successCriteria ) {
512- const passedSuccessCriteria = this . hasPassedSuccessCriteria ( ) ;
513-
514- if ( passedSuccessCriteria ) {
515- this . logger . success ( "All criteria checks passed" ) ;
516- if ( this . currentRetryRule ) {
517- if ( this . retryContext . doNotDeleteRetryLimits ) {
518- this . retryLimits [ this . currentRetryRule ] = 0 ;
519- this . logger . notice ( "Retries stopped" ) ;
520- }
535+ const passedSuccessCriteria = this . hasPassedSuccessCriteria ( ) ;
536+
537+ if ( passedSuccessCriteria ) {
538+ this . logger . success ( "All criteria checks passed" ) ;
539+ if ( this . currentRetryRule ) {
540+ if ( this . retryContext . doNotDeleteRetryLimits ) {
541+ this . retryLimits [ this . currentRetryRule ] = 0 ;
542+ this . logger . notice ( "Retries stopped" ) ;
521543 }
544+ }
522545
523- await this . dealWithPassedRule ( response ) ;
546+ await this . dealWithPassedRule ( response ) ;
547+ } else {
548+ this . logger . error ( "Not all criteria checks passed" ) ;
549+ if ( this . step . onFailure ) {
550+ await this . dealWithFailedRule ( ) ;
524551 } else {
525- this . logger . error ( "Not all criteria checks passed" ) ;
526- if ( this . step . onFailure ) {
527- await this . dealWithFailedRule ( ) ;
528- } else {
529- throw new Error (
530- `${ this . step . stepId } step of the ${ this . workflow . workflowId } workflow failed the successCriteria` ,
531- ) ;
532- }
552+ throw new Error (
553+ `${ this . step . stepId } step of the ${ this . workflow . workflowId } workflow failed the successCriteria` ,
554+ ) ;
533555 }
534556 }
535557 } else {
@@ -843,14 +865,7 @@ class Arazzo extends Document {
843865 * @private
844866 * @param {* } response
845867 */
846- async dealWithStepOutputs ( response ) {
847- const json = await response ?. json ( ) . catch ( ( err ) => {
848- this . logger . error ( `Error trying to resolve ${ this . step . stepId } outputs` ) ;
849- throw new Error ( err ) ;
850- } ) ;
851-
852- this . expression . addToContext ( "response.body" , json ) ;
853-
868+ async dealWithStepOutputs ( ) {
854869 const outputs = { } ;
855870 for ( const key in this . step . outputs ) {
856871 const value = this . expression . resolveExpression ( this . step . outputs [ key ] ) ;
0 commit comments