我正在针对 AWS WAF 编写一个测试,除其他外,它还会检查是否缺少 User-Agent 标头。
设置configure headers = null并手动添加其他必需的标头仍然会生成不需要的User-Agent标头。有办法抑制吗?将其设置为 null 是不够的。
Feature:
Background:
* url url
* path path
* configure headers = null
Scenario:
Given header x-api-key = key
And request payload
When method post
Then status 200
生成的请求:
1 > Content-Type: application/json; charset=UTF-8
1 > Content-Length: 189
1 > Host: blah.cloudfront.net
1 > Connection: Keep-Alive
1 > User-Agent: Apache-HttpClient/4.5.14 (Java/17.0.8.1)
1 > Accept-Encoding: gzip,deflate
{blah}
Karate 使用 Apache HTTP 客户端,看起来在较新的版本中,可以禁用此标头的发送:https://issues.apache.org/jira/browse/HTTPCLIENT-1952
这需要更改代码。请随意提出功能请求。如果你能提交 PR 会更快。
同时,您可以考虑以下方法:https://stackoverflow.com/a/56462226/143475