Cara Nggawe Multiple Header ing Panyuwunan HTTP Kanthi Karate

Kepiye cara nyetel header HTTP ing Karate?

Karate minangka alat uji coba API kanthi DSL sing komprehensif lan gampang dingerteni.

Ing postingan iki, kita nuduhake cara nyetel pirang-pirang header ing bagean header saka panjaluk.


Tuladhane kalebu Agen pangguna, Jinis Konten, Enkode Penerimaan, Sambungan, lsp.

Ana sawetara cara kanggo nyetel header panjaluk ing Karate:




Nggunakake header

Sampeyan bisa nggunakake header tembung kunci kaping pirang-pirang ing panjaluk



Given header Content-Type = 'text/xml;charset=ISO-8859-1'
And header Accept-Encoding = 'gzip,deflate'
And header Connection = 'Keep-Alive'
And header Expect = '100-continue'
And header User-Agent = 'Mozilla/4.0(compatible;IE;GACv7. 1. 5192. 22378)'
And header Host = 'localhost'
When url 'http://www.example.com'
And request { some: 'data' }
When method post
Then status 200


Nggunakake header

Sampeyan uga bisa nemtokake macem-macem header ing variabel banjur gunakake ing headers tembung kunci kanggo ngirim kabeh header panjaluk

* def req_headers = {Content-Type: 'text/xml;charset=ISO-8859-1', Connection: 'Keep-Alive', User-Agent: 'Mozilla/4.0(compatible;IE;GACv7. 1. 5192. 22378)'} Given headers req_headers
And url 'http://www.example.com'
And request { some: 'data' }
When method post
Then status 200

Nggunakake header configure

Cara liya kanggo nyetel header panjaluk yaiku nggunakake configure headers

* configure headers = {Content-Type: 'text/xml;charset=ISO-8859-1', Connection: 'Keep-Alive', User-Agent: 'Mozilla/4.0(compatible;IE;GACv7. 1. 5192. 22378)'} Given url 'http://www.example.com' And request { some: 'data' } When method post Then status 200