Forum Discussion
JHunt
7 years agoCommunity Hero
You can put a Groovy Script in between your two requests:
def cookies = [] testRunner.testCase.getTestStepByName("1st test step").testRequest.response.responseHeaders.each { if (it.key == "Set-Cookie") cookies += it.value } def cookieValue = "" cookies.each { cookieValue += "${it};" } cookieValue = cookieValue.substring(0, cookieValue.length() - 1) testRunner.testCase.getTestStepByName("2nd test step").testRequest.requestHeaders += ["Cookie": [cookieValue]]
Response for "1st test step" REST Test Step:
HTTP/1.1 200 OK Set-Cookie: sessionid=abc Set-Cookie: token1=def Content-Type: application/json Content-Encoding: gzip Content-Length: 41 Server: Jetty(6.1.26) {"Something":"Reply"}
Request for "2nd test step" REST Test Step:
POST http://localhost:8081/me HTTP/1.1 Accept-Encoding: gzip,deflate Content-Type: application/json;charset=UTF-8 Cookie: sessionid=abc;token1=def Content-Length: 0 Host: localhost:8081 Connection: Keep-Alive User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
Related Content
- 10 years ago
- 12 years ago
- 9 years ago
Recent Discussions
- 14 hours ago