I want to print all the response headers in the log. How can i do that without knowing the header names? Do i need to add a javascript to iterate through the headers array?
Thanks,
Krish
Hi @Krish,
You can use below snippet of Javascript and print all the headers in the request/response just replace "request" with "response".
var headerNames = context.getVariable('request.headers.names'); var headerCount = context.getVariable('request.headers.count'); //Most important : request.headers.names give a Java Set object so convert it to string array. headerNames = headerNames.toArray(); for (var i = 0; i < headerNames.length; i++) { print(headerNames[i] + ":" + context.getVariable('request.header.'+headerNames[i].toLowerCase())); }
Cheers!!
Thanks @Mohammed Zuber. I was wondering if there is a way to do this without adding a javascript.
-Krish