如何使用Karate仅发送"application/json"作为内容类型标头? [英] How can I send just 'application/json' as the content-type header with Karate?

查看:92
本文介绍了如何使用Karate仅发送"application/json"作为内容类型标头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我无法控制的服务编写我的第一个测试.该服务验证传入请求的标头,对于内容类型标头,它要求该值是application/json,并且仅该值.但是,当我尝试编写测试并将内容类型标头设置为仅具有此值时,生成的标头将具有以下值:application/json; charset=UTF-8

I'm trying to write my first test for a service that I have no control over. The service validates headers on incoming requests and for the content-type header it requires that the value be application/json, and only that value. However when I try to write a test and explicitly set the content-type header to only have this value, the header that is generated has the following value instead: application/json; charset=UTF-8

此额外的charset=UTF-8值阻止我的测试通过.反正有什么办法阻止空手道添加它?

This additional charset=UTF-8 value is preventing my test from passing. Is there anyway to prevent Karate from adding it?

推荐答案

Content-Type上的UTF-8默认设置可以被

* configure charset = null

请参考空手道文档

这篇关于如何使用Karate仅发送"application/json"作为内容类型标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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