public void parseHttpConn()

in src/main/java/com/aliyun/credentials/http/CompatibleUrlConnClient.java [179:218]


    public void parseHttpConn(HttpResponse response, HttpURLConnection httpConn, InputStream content, Exception e) {
        byte[] buff;
        try {
            if (null != content) {
                buff = readContent(content);
            } else {
                response.setResponseMessage(e.getMessage());
                return;
            }
            response.setResponseCode(httpConn.getResponseCode());
            response.setResponseMessage(httpConn.getResponseMessage());
            Map<String, List<String>> headers = httpConn.getHeaderFields();
            for (Entry<String, List<String>> entry : headers.entrySet()) {
                String key = entry.getKey();
                if (null == key) {
                    continue;
                }
                List<String> values = entry.getValue();
                StringBuilder builder = new StringBuilder(values.get(0));
                for (int i = 1; i < values.size(); i++) {
                    builder.append(",");
                    builder.append(values.get(i));
                }
                response.putHeaderParameter(key, builder.toString());
            }
            String type = response.getHeaderValue("Content-Type");
            if (null != buff && null != type) {
                response.setSysEncoding("UTF-8");
                String[] split = type.split(";");
                response.setHttpContentType(FormatType.mapAcceptToFormat(split[0].trim()));
                if (split.length > 1 && split[1].contains("=")) {
                    String[] codings = split[1].split("=");
                    response.setSysEncoding(codings[1].trim().toUpperCase());
                }
            }
            response.setHttpContent(buff, response.getSysEncoding(), response.getHttpContentType());
        } catch (Exception exception) {
            throw new CredentialException(exception.getMessage(), exception);
        }
    }