private ResponseMessage sendRequestImpl()

in src/main/java/com/aliyun/openservices/log/http/comm/ServiceClient.java [82:122]


    private ResponseMessage sendRequestImpl(RequestMessage request,
                                            String charset) throws ClientException, ServiceException {
        InputStream requestContent = request.getContent();

        if (requestContent != null && requestContent.markSupported()) {
            requestContent.mark(DEFAULT_MARK_LIMIT);
        }

        int retries = 0;
        RetryStrategy retryStrategy = config.getRetryStrategy() != null ? config.getRetryStrategy()
                : this.getDefaultRetryStrategy();

        while (true) {
            try {
                if (retries > 0) {
                    pause(retries, retryStrategy);
                    if (requestContent != null && requestContent.markSupported()) {
                        try {
                            requestContent.reset();
                        } catch (IOException ex) {
                            throw new ClientException("Failed to reset the request input stream: ", ex);
                        }
                    }
                }
                Request httpRequest = buildRequest(request, charset);
                return sendRequestCore(httpRequest, charset);
            } catch (ServiceException sex) {
                if (!shouldRetry(sex, request, retries, retryStrategy)) {
                    throw sex;
                }
            } catch (ClientException cex) {
                if (!shouldRetry(cex, request, retries, retryStrategy)) {
                    throw cex;
                }
            } catch (Exception ex) {
                throw new ClientException(ex.getMessage(), ex);
            } finally {
                retries++;
            }
        }
    }