private HttpResponse doPostForHttpResponse()

in aliyun-sdk-opensearch/src/main/java/com/aliyun/opensearch/util/HttpClientFactory.java [295:334]


    private <T extends HttpRequestBase> HttpResponse doPostForHttpResponse(String reqURL, Map<String, String> headers,
                                                          String encoding,
                                                          T httpRequest) throws IOException {
        // 请求开始
        this.clientTracer.start(httpRequest.getMethod(), reqURL);

        httpRequest.setHeader("User-Agent", "opensearch/java sdk " + version);
        if (this.gzip) {
            httpRequest.setHeader("Accept-Encoding", "gzip");
        }

        for (Entry<String, String> header : headers.entrySet()) {
            httpRequest.setHeader(header.getKey(), header.getValue());
        }
        LOG.debug("--------POST Headers: --------");
        for (Header header : httpRequest.getAllHeaders()) {
            LOG.debug(header.toString());
        }
        LOG.debug("--------------------------------");
        LOG.debug("httpRequest: " + httpRequest);

        // 发送请求
        this.clientTracer.send(httpRequest);

        HttpResponse response;
        try {
            response = httpClient.execute(httpRequest);
            validateResponse(response, httpRequest);
        } catch (RuntimeException e) {
            // 请求失败
            this.clientTracer.fail();
            throw e;
        } catch (IOException e) {
            // 请求失败
            this.clientTracer.fail();
            throw e;
        }

        return response;
    }