空手道自动设置 Content-Type 标头 [英] Karate automatically sets Content-Type header

查看:48
本文介绍了空手道自动设置 Content-Type 标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天!在我的负面测试用例中,我必须 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆