Skip to content

Instantly share code, notes, and snippets.

@rngtng
Created December 5, 2021 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rngtng/415c1d7005bc3b81f02b219d2d1cadd1 to your computer and use it in GitHub Desktop.
Save rngtng/415c1d7005bc3b81f02b219d2d1cadd1 to your computer and use it in GitHub Desktop.
Testing httpyac action sequence
{{
console.log('Global script')
}}
### Request1
{{
console.log('R1: Local script 1 ' + (typeof response !== 'undefined'));
}}
{{+request
console.log('R1: +request ' + (typeof response !== 'undefined'));
}}
{{+streaming
console.log('R1: +streaming ' + (typeof response !== 'undefined'));
}}
{{+response
console.log('R1: +response ' + (typeof response !== 'undefined'));
}}
{{+responseLogging
console.log('R1: +responseLogging ' + (typeof response !== 'undefined'));
}}
{{+after
console.log('R1: +after ' + (typeof response !== 'undefined'));
}}
{{
console.log('R1: Local script 2 ' + (typeof response !== 'undefined'));
}}
{{@request
console.log('R1: @request ' + (typeof response !== 'undefined'));
}}
{{@streaming
console.log('R1: @streaming ' + (typeof response !== 'undefined'));
}}
{{@response
console.log('R1: @response ' + (typeof response !== 'undefined'));
}}
{{@responseLogging
console.log('R1: @responseLogging ' + (typeof response !== 'undefined'));
}}
{{@after
console.log('R1: @after ' + (typeof response !== 'undefined'));
}}
{{
console.log('R1: Local script 3 ' + (typeof response !== 'undefined'));
}}
GET https://httpbin.org/status/200
{{
console.log('R1: Local script 4 ' + (typeof response !== 'undefined'));
}}
### Request2
{{
console.log('R2: Local script 1 ' + (typeof response !== 'undefined'));
}}
{{+request
console.log('R2: +request ' + (typeof response !== 'undefined'));
}}
{{+streaming
console.log('R2: +streaming ' + (typeof response !== 'undefined'));
}}
{{+response
console.log('R2: +response ' + (typeof response !== 'undefined'));
}}
{{+responseLogging
console.log('R2: +responseLogging ' + (typeof response !== 'undefined'));
}}
{{+after
console.log('R2: +after ' + (typeof response !== 'undefined'));
}}
{{
console.log('R2: Local script 2 ' + (typeof response !== 'undefined'));
}}
{{@request
console.log('R2: @request ' + (typeof response !== 'undefined'));
}}
{{@streaming
console.log('R2: @streaming ' + (typeof response !== 'undefined'));
}}
{{@response
console.log('R2: @response ' + (typeof response !== 'undefined'));
}}
{{@responseLogging
console.log('R2: @responseLogging ' + (typeof response !== 'undefined'));
}}
{{@after
console.log('R2: @after ' + (typeof response !== 'undefined'));
}}
{{
console.log('R2: Local script 3 ' + (typeof response !== 'undefined'));
}}
GET https://httpbin.org/status/201
{{
console.log('R2: Local script 4 ' + (typeof response !== 'undefined'));
}}

Results

Output of httpyac actions.http -o short:

Request1

Global script

---------------------

=== Request1 ===

GET https://httpbin.org/status/200
=> 200 (476 ms, 184 B)
R1: Local script 1 false
R1: @after false
R1: Local script 2 false
R1: @after false
R1: Local script 3 false
R1: @after false
R1: @after false
R1: +request false
R2: +request false
R1: @request false
R1: @response true
R1: +response true
R2: +response true
R1: @after true
R1: Local script 4 true
R1: @after true
R1: +after true
R2: +after true
R1: +responseLogging true
R2: +responseLogging true
R1: @responseLogging true

Request 2

Global script

---------------------

=== Request2 ===

GET https://httpbin.org/status/201
=> 201 (467 ms, 184 B)
R2: Local script 1 false
R2: @after false
R2: Local script 2 false
R2: @after false
R2: Local script 3 false
R2: @after false
R2: @after false
R1: +request false
R2: +request false
R2: @request false
R2: @response true
R1: +response true
R2: +response true
R2: @after true
R2: Local script 4 true
R2: @after true
R1: +after true
R2: +after true
R1: +responseLogging true
R2: +responseLogging true
R2: @responseLogging true

All

Global script

---------------------

=== Request1 ===

GET https://httpbin.org/status/200
=> 200 (444 ms, 184 B)
R1: Local script 1 false
R1: @after false
R1: Local script 2 false
R1: @after false
R1: Local script 3 false
R1: @after false
R1: @after false
R1: +request false
R2: +request false
R1: @request false
R1: @response true
R1: +response true
R2: +response true
R1: @after true
R1: Local script 4 true
R1: @after true
R1: +after true
R2: +after true
R1: +responseLogging true
R2: +responseLogging true
R1: @responseLogging true

---------------------

=== Request2 ===

GET https://httpbin.org/status/201
=> 201 (341 ms, 184 B)
R2: Local script 1 true
R2: @after true
R2: Local script 2 true
R2: @after true
R2: Local script 3 true
R2: @after true
R2: @after true
R1: +request true
R2: +request true
R2: @request true
R2: @response true
R1: +response true
R2: +response true
R2: @after true
R2: Local script 4 true
R2: @after true
R1: +after true
R2: +after true
R1: +responseLogging true
R2: +responseLogging true
R2: @responseLogging true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment