dromara / hutool

🍬A set of tools that keep Java sweet.
https://hutool.cn
Other
28.91k stars 7.48k forks source link

HttpUtil post 响应结果乱码问题 #3672

Closed shixiaoxianga closed 1 month ago

shixiaoxianga commented 1 month ago

version:5.8.29

抓包工具响应结果

image

代码如下

    HttpResponse httpResponse = HttpUtil.createPost(checkTicketUserCardApi)
            .body(bodyJson)
            .charset(StandardCharsets.UTF_8)
            .addResponseInterceptor(new HttpInterceptor<HttpResponse>() {
                @Override
                public void process(HttpResponse httpObj) {
                    System.out.println("1");
                }
            })
            .headerMap(headerMap, true)
            .execute();
    int status = httpResponse.getStatus();
    String data = httpResponse.body();

接口响应头中的 Content-Type 也是 application/json;charset=UTF-8

打印data : F�֙���'�6&8�Jd[9�eA�Tĩ(�}'H$A8�a+Hވۍ@(b�;C!�\Vwȉ@����렼��%��oj���LH�d(�"(���9�$-���~��tf�kʣ������Ԍ��,ֵ���u��JNe n

我查看httpResponse.body字节长度为137实际应该不会这么少的(个人猜测作者可忽略)

shixiaoxianga commented 1 month ago

已解决