本文介绍了KARATE:lowerCaseResponseHeaders也以小写形式设置为true,将参数的值设置在redirect_uri中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在测试环境之一中使用karate.configure('lowerCaseResponseHeaders', true).但是问题在于,它将状态的值以小写形式放置在redirect_uri中,该值在POST请求的responseHeaders.location中返回.示例:

I would like to use karate.configure('lowerCaseResponseHeaders', true) for one of test environments. But the problem is that it puts in lower case a state's value in redirect_uri which is returned in responseHeaders.location of a POST request. Example:

位置的返回值:

location: https://www.example.com/bar?state=ReturnedValueForState

值用karate.configure('lowerCaseResponseHeaders', true)

location: https://www.example.com/bar?state=returnedvalueforstate

我必须使用原始的返回值,否则当我使用redirect_uri时会得到404 Not Found.空手道中是否有解决方案,可以跳过responseHeaders中项目的值,而仅将项目名称小写?

I have to use the original returned value, otherwise I get a 404 Not Found when I use the redirect_uri. Is there a solution in karate to skip items' value in responseHeaders and put only items' names in lower case?

推荐答案

我找到了解决此问题的方法,但不适用于其他responseHeader.这是我的解决方案:在karate-config.js中,我放了

I found a way to deal with this but it doesn't work for other responseHeaders. Here is my solution: in karate-config.js I put

  • location: 'location'作为环境变量,用于返回小写字母

  • location: 'location' as environment variable for one which returns location in lower case

location: 'Location'用于返回大写位置的环境.然后在特征中,我可以获得位置的值:`

location: 'Location' for an environment which return location in upper case. Then in features I can get location's value: `

 * def location = responseHeaders[location][0]`
 * def foo = location.substring(location.lastIndexOf('/') + 2)

不适用于PSU-User-Agent之类的标头.响应为Could not parse token starting at position 1. Expected ?, ', 0-9, *

It doesn't work for headers such as PSU-User-Agent. The response is Could not parse token starting at position 1. Expected ?, ', 0-9, *

我在这里阅读了有关此问题的信息,但未发现任何问题: https://github .com/intuit/karate/issues/504 .

I read here about this problem but didn't find any issue: https://github.com/intuit/karate/issues/504.

我们使用最新的空手道版本:0.9.4.

We use the latest karate version: 0.9.4.

为什么在空手道回应中标题检查保持区分大小写?而在http协议中,它应不区分大小写. 感谢您的答复

Why in karate responseHeaders checks stay case sensitive? while in http protocol it should be case insensitive. Thanks for your reply

这篇关于KARATE:lowerCaseResponseHeaders也以小写形式设置为true,将参数的值设置在redirect_uri中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 11:46