olp-cpp-sdk 1.24.0
Loading...
Searching...
No Matches
NetworkSettings.h
1/*
2 * Copyright (C) 2019-2024 HERE Europe B.V.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * SPDX-License-Identifier: Apache-2.0
17 * License-Filename: LICENSE
18 */
19
20#pragma once
21
22#include <chrono>
23#include <cstdint>
24#include <string>
25#include <vector>
26
27#include <olp/core/CoreApi.h>
28#include <olp/core/http/NetworkProxySettings.h>
29#include <olp/core/http/NetworkTypes.h>
30#include <olp/core/porting/deprecated.h>
31
32namespace olp {
33namespace http {
34
38class CORE_API NetworkSettings final {
39 public:
45 std::chrono::milliseconds GetConnectionTimeoutDuration() const;
46
47#ifdef OLP_SDK_NETWORK_IOS_BACKGROUND_DOWNLOAD
53 std::chrono::milliseconds GetBackgroundConnectionTimeoutDuration() const;
54#endif // OLP_SDK_NETWORK_IOS_BACKGROUND_DOWNLOAD
55
63 NetworkSettings& WithConnectionTimeout(std::chrono::milliseconds timeout);
64
65#ifdef OLP_SDK_NETWORK_IOS_BACKGROUND_DOWNLOAD
73 NetworkSettings& WithBackgroundConnectionTimeout(
74 std::chrono::milliseconds timeout);
75#endif // OLP_SDK_NETWORK_IOS_BACKGROUND_DOWNLOAD
76
82 std::chrono::milliseconds GetTransferTimeoutDuration() const;
83
89 std::chrono::seconds GetMaxConnectionLifetime() const;
90
98 NetworkSettings& WithMaxConnectionLifetime(std::chrono::seconds lifetime);
99
107 NetworkSettings& WithTransferTimeout(std::chrono::milliseconds timeout);
108
115
124
130 const std::vector<std::string>& GetDNSServers() const;
131
143 NetworkSettings& WithDNSServers(std::vector<std::string> dns_servers);
144
145 private:
147 std::chrono::milliseconds connection_timeout_ = std::chrono::seconds(60);
148#ifdef OLP_SDK_NETWORK_IOS_BACKGROUND_DOWNLOAD
150 std::chrono::milliseconds background_connection_timeout_ =
151 std::chrono::seconds(600);
152#endif // OLP_SDK_NETWORK_IOS_BACKGROUND_DOWNLOAD
154 std::chrono::milliseconds transfer_timeout_ = std::chrono::seconds(30);
156 std::chrono::seconds connection_lifetime_{0};
158 NetworkProxySettings proxy_settings_;
160 std::vector<std::string> dns_servers_;
161};
162
163} // namespace http
164} // namespace olp
Contains a proxy configuration for the network interface that is applied per request.
Definition NetworkProxySettings.h:34
Contains a configuration for the network.
Definition NetworkSettings.h:38
NetworkSettings & WithConnectionTimeout(std::chrono::milliseconds timeout)
Sets the connection timeout.
std::chrono::milliseconds GetTransferTimeoutDuration() const
Gets the transfer timeout.
NetworkSettings & WithMaxConnectionLifetime(std::chrono::seconds lifetime)
Sets max lifetime (since creation) allowed for reusing a connection. Supported only for CURL implemen...
std::chrono::milliseconds GetConnectionTimeoutDuration() const
Gets the connection timeout.
NetworkSettings & WithDNSServers(std::vector< std::string > dns_servers)
Sets the DNS servers to use. Works only with CURL implementation. The order is important....
std::chrono::seconds GetMaxConnectionLifetime() const
Gets max lifetime (since creation) allowed for reusing a connection.
NetworkSettings & WithTransferTimeout(std::chrono::milliseconds timeout)
Sets the transfer timeout.
NetworkSettings & WithProxySettings(NetworkProxySettings settings)
Sets the proxy settings.
const NetworkProxySettings & GetProxySettings() const
Gets the proxy settings.
const std::vector< std::string > & GetDNSServers() const
Gets the DNS list.
Rules all the other namespaces.
Definition AppleSignInProperties.h:24