我正在使用https://github.com/jayway/rest-assured(版本 3.2.1)来测试 REST API,但我在设置 Content-Type 时遇到问题。
我正在做以下测试,
@Test
public void testSendContentType(){
String str = givenThat()
.when()
.contentType(ContentType.URLENC)
.get(URL).asString();
System.out.println(str);
}
执行测试后,我设置了以下标题。
捕获的标头
Expires: Mon, 30 Jun 2014 14:33:21 GMT
Vary: Accept-Encoding
Content-Encoding: gzip
Connection: close
Transfer-Encoding: chunked
Content-Type: application/json;charset=utf-8
我调试并查看了代码,但我无法理解内容类型是如何设置的,以及为什么它没有设置我提供的内容类型。
我也尝试了以下但没有奏效
.header("Content-Type", ""application/x-www-form-urlencoded")