public String toJson(String headers){
        String [] s = headers.split("\n");
        Map<String,String> map=new HashMap<>();
        for (String st : s){
            map.put(st.substring(0, st.indexOf(":")).trim(),st.substring(st.indexOf(":")+1).trim());
        }
        return JSONObject.toJSONString(map);
    }

响应头格式

access-control-allow-credentials: true
access-control-allow-origin: http://localhost
cache-control: no-cache, no-store, max-age=0, must-revalidate
connection: close
content-type: application/json;charset=UTF-8
date: Wed, 08 Sep 2021 10:03:20 GMT
expires: 0
pragma: no-cache
transfer-encoding: chunked
vary: Origin, Access-Control-Request-Method, Access-Control-Request-Headers
x-content-type-options: nosniff
X-Powered-By: Express
x-xss-protection: 1; mode=block

Q.E.D.


Nothing really matters to me!