空手道自动设置 Content-Type 标头 [英] Karate automatically sets Content-Type header
问题描述
美好的一天!在我的负面测试用例中,我必须 PUT 一个没有 Content-Type 标头的请求,以匹配所需的 4xx 状态代码.问题是空手道会自动设置适当的 Content-Type.例如.当我将 {} 作为请求传递时,它会设置 application/json;字符集=UTF-8当我将 '' 作为请求传递时,它会设置 text/plain;charset=UTF-8
Good day! In my negative test cases I have to PUT a request without Content-Type header in order to match desired 4xx status code. The problem is karate automatically sets an appropriate Content-Type. E.g. when I pass {} as request it sets application/json; charset=UTF-8 when I pass '' as request it sets text/plain; charset=UTF-8
问题是如何发送没有 Content-Type 标头的 PUT 请求?
The question is how can I send a PUT request without a Content-Type header?
推荐答案
您可以使用以下行传递 Content-Type:
You can pass Content-Type by using the below line:
并且标头 Content-Type = 'application/json;charset=utf-8'
这篇关于空手道自动设置 Content-Type 标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!