Realm C++ SDK版本 v 2.2.0

http.hpp

1
2//
3// 版权所有 2024 Realm Inc.
4//
5// 根据 Apache 许可证 2.0 版(“许可证”)获得许可;
6// 除非符合合规,否则不得使用此文件。
7// 您可以在以下网址获取许可证副本:
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// 除非适用法律要求或书面同意,否则软件
12// 根据许可证分发是按“原样”分发的,
13// 不提供任何类型的Express或暗示的保证或条件。
14// 请参阅管理权限的特定语言的许可证和
15// 许可证下的限制。
16//
18
19#ifndef CPPREALM_NETWORKING_HTTP_HPP
20#define CPPREALM_NETWORKING_HTTP_HPP
21
22#include <cpprealm/internal/bridge/realm.hpp>
23
24#ifndef REALMCXX_VERSION_MAJOR
25#include <cpprealm/version_numbers.hpp>
26#endif
27
28#include<optional>
29#include <map>
30#include <string>
31
32命名空间域::networking {
33
37 枚举 class http_method { get, 帖子, patch, put, del };
41 using http_headers = std::map<std::string, std::string>;
42
46 struct request {
50 http_method method = http_method::get;
51
55 std::string URL
56
61 uint 64 _t timeout_ms = 0 ;
62
66 http_headers headers
67
71 std::string body
72 };
73
77 struct 响应{
82
87
91 http_headers headers
92
96 std::string body
97
101 std::Optional<std::int 32 _t> client_error_code
102
103 };
104
105 // 用于提供HTTP传输的接口
107 虚拟 ~http_transport_client () = 默认 ;
108 虚拟 void send_request_to_server( const 请求 & 请求 ,
109 std::function< void ( const response &)>&& Completion) = 0 ;
110 };
111
113 std::shared_ptr<http_transport_client> make_http_client();
115 [[maybe_unused]] void set_http_client_factory(std::function<std::shared_ptr<http_transport_client>()>&&);
116
119 struct 配置{
123 std::Optional<std::map<std::string, std::string>> custom_http_headers
127std::Optional<::realm::internal::bridge::realm::sync_config::proxy_config> proxy_config
128
129 using SSLVerifyCallback = bool( const std::string& server_address,
130 internal::bridge:: 域::sync_config::proxy_config::port_type server_port,
131 const char* pem_data, size_t pem_size, int preverify_ok, int depth);
139 std::Optional<std::string> ssl_trust_certificate_path
145 std::function<SSLVerifyCallback> ssl_verify_callback
146 };
147
148 default_http_transport() = default;
149 default_http_transport ( const configuration & c) : m_configuration(c) {}
150
151 ~default_http_transport () = 默认 ;
152
153 void send_request_to_server(const:: 域::networking::request& 请求
154 std::function< void (const:: 域::networking::response&)>&&completion);
155
156 protected
157配置 m_configuration;
158 };
159 }
160
161#endif //CPPREALM_NETWORKING_HTTP_HPP
std::Optional<::realm::internal::bridge::realm::sync_config::proxy_config > proxy_config
Definition: http.hpp:127
std::option< std::string > ssl_trust_certificate_path
Definition: http.hpp:139
std::function< SSLVerifyCallback > ssl_verify_callback
Definition: http.hpp:145
std::optional< std::map< std::string, std::string > > custom_http_headers
Definition: http.hpp:123
内置HTTP传输客户端。
Definition: http.hpp:118
Definition: http.hpp:46
http_headers headers
Definition: http.hpp:66
std::string 体
Definition: http.hpp:71
uint 64 _t timeout_ms
Definition: http.hpp:61
http_method 方法
Definition: http.hpp:50
std::string URL
Definition: http.hpp:55
Definition: http.hpp:77
std::string 体
Definition: http.hpp:96
http_headers headers
Definition: http.hpp:91
std::Optional< std::int 32 _t > client_error_code
Definition: http.hpp:101
int custom_status_code
Definition: http.hpp:86
int http_status_code
Definition: http.hpp:81