无法从空手道中的响应标头获取"Location"属性



我无法从空手道中的响应标头中获取位置属性,而使用下面的代码时会显示其他标头,也可以从邮递员那里看到所有标头,包括位置

Background: 
* url APAuthorizationURL
* def sessionTokenPayload = call read('DIGI-3049.feature')
* def authToken = sessionTokenPayload.session_Token
* configure cors = true
* print authToken
@Authorization
Scenario: Authorization_100200
Given header Content-Type = 'application/json'
* print authToken
* def query = {client_id: '0oajtiuveymO1ES7G0h7',response_type : 'token',response_mode:     'okta_post_message', redirect_uri: 'https%3A%2F%2Fqa2-sc.adviser.ad.mlclife.com.au',    scope:'advisor',prompt:'none',state:'203475b6-836d-4dcb-8a12-7b2b2b3a2cf9', sessionToken :  'authToken', nonce:'158261204839000', scope : 'advisor' }
And params query
When method get
Then status 200
* print responseHeaders / location header is not printing
* print 'headers:', karate.prevRequest.headers / location header is not printing

这对我来说很好。请将其粘贴到新的Scenario中,然后尝试:

* url 'http://httpbin.org'
* path 'redirect-to'
* param url = 'http://httpbin.org/get'
* param status_code = 200
* method get

第一个请求响应是:

19:04:20.612 [main] DEBUG com.intuit.karate - request:
1 > GET http://httpbin.org/redirect-to?url=http%3A%2F%2Fhttpbin.org%2Fget&status_code=200
1 > Accept-Encoding: gzip,deflate
1 > Connection: Keep-Alive
1 > Host: httpbin.org
1 > User-Agent: Apache-HttpClient/4.5.11 (Java/1.8.0_231)
19:04:21.287 [main] DEBUG com.intuit.karate - response time in milliseconds: 670.62
1 < 302
1 < Access-Control-Allow-Credentials: true
1 < Access-Control-Allow-Origin: *
1 < Connection: keep-alive
1 < Content-Length: 0
1 < Content-Type: text/html; charset=utf-8
1 < Date: Tue, 25 Feb 2020 13:34:21 GMT
1 < Location: http://httpbin.org/get
1 < Server: gunicorn/19.9.0

所以你一定是错过了什么,或者向错误的终点提出了错误的请求。此外,请务必阅读文档中有关followRedirects配置的内容。

最新更新