I've got a Response file with 3 cookies that have the same name (Site-Cookie) and I need to set 3 headers with the name Site-Cookie I'm using the headers.put(<name>,<value>), but it only creates 1 header and then overwrites the value held in it.
import com.eviware.soapui.support.types.StringToStringMap
def headers = new StringToStringMap()
def cookie_name0 = testRunner.testCase.testSteps["ServiceWTm.svc 1 - SessionLogon"].testRequest.response.responseHeaders["Set-Cookie"][0]
def cookie_name1 = testRunner.testCase.testSteps["ServiceWTm.svc 1 - SessionLogon"].testRequest.response.responseHeaders["Set-Cookie"][1]
def cookie_name2 = testRunner.testCase.testSteps["ServiceWTm.svc 1 - SessionLogon"].testRequest.response.responseHeaders["Set-Cookie"][2]
headers.put("Set-Cookie",cookie_name0)
headers.put("Set-Cookie",cookie_name1)
headers.put("Set-Cookie",cookie_name2)
testRunner.testCase.getTestStepByName("ServiceWTm.svc 1 - TransactionStart").testRequest.setRequestHeaders(headers)
I end up with one Header called "Set-Cookie" with the value of cookie_name2 in it.
Is there another method I can use other than header.put or another way to approach this?
use StringToStringsMap instead of StringToStringMap
def headers = testRequest.getRequestHeaders() //returns StringToStringsMap
headers.add("Set-Cookie",cookie0)
headers.add("Set-Cookie",cookie1)
headers.add("Set-Cookie",cookie2)
testRequest.setRequestHeaders(headers)