std::shared_ptr HttpClientConnectionManager::NewClientConnectionManager()

in source/http/HttpConnectionManager.cpp [36:75]


            std::shared_ptr<HttpClientConnectionManager> HttpClientConnectionManager::NewClientConnectionManager(
                const HttpClientConnectionManagerOptions &connectionManagerOptions,
                Allocator *allocator) noexcept
            {
                const Optional<Io::TlsConnectionOptions> &tlsOptions =
                    connectionManagerOptions.ConnectionOptions.TlsOptions;

                if (tlsOptions && !(*tlsOptions))
                {
                    AWS_LOGF_ERROR(
                        AWS_LS_HTTP_GENERAL,
                        "Cannot create HttpClientConnectionManager: ConnectionOptions contain invalid TLSOptions.");
                    aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
                    return nullptr;
                }

                const Crt::Optional<Crt::Http::HttpClientConnectionProxyOptions> &proxyOptions =
                    connectionManagerOptions.ConnectionOptions.ProxyOptions;

                if (proxyOptions && proxyOptions->TlsOptions && !(*proxyOptions->TlsOptions))
                {
                    AWS_LOGF_ERROR(
                        AWS_LS_HTTP_GENERAL,
                        "Cannot create HttpClientConnectionManager: ProxyOptions has ConnectionOptions that contain "
                        "invalid TLSOptions.");
                    aws_raise_error(AWS_ERROR_INVALID_ARGUMENT);
                    return nullptr;
                }

                auto *toSeat = static_cast<HttpClientConnectionManager *>(
                    aws_mem_acquire(allocator, sizeof(HttpClientConnectionManager)));
                if (toSeat)
                {
                    toSeat = new (toSeat) HttpClientConnectionManager(connectionManagerOptions, allocator);
                    return std::shared_ptr<HttpClientConnectionManager>(
                        toSeat, [allocator](HttpClientConnectionManager *manager) { Delete(manager, allocator); });
                }

                return nullptr;
            }