HttpRequest 设置表单内容类型无效
@Test
public void getImgCode() {
Map<String, Object> param = new HashMap<>();
param.put("userId", "11111");
HttpRequest request = HttpRequest.post(baseUrl + "openapi/api/v2/getCode")
.header("content-type","application/json;charset=utf-8")
.form(param);
System.out.println(request.contentType());
HttpResponse response = request.send();
System.out.println(response.bodyText());
}
但打印内容类型 = application/x-www-form-urlencoded;charset=utf-8
如果使用httpQequest.query(param)
so 没问题,但查询只支持字符串。