![]() |
RMVL
2.5.0-dev
Robotic Manipulation and Vision Library
|
提供跨平台的同步异步 Socket 通信、HTTP 请求、HTTP Web 后端框架功能 更多...
命名空间 | |
| namespace | rm::ip |
| IP 协议族,包含 IPv4 和 IPv6 以及多播选项的相关定义 | |
类型定义 | |
| using | rm::ResponseMiddleware = std::function<void(const Request &, Response &)> |
| 响应中间件类型 | |
| using | rm::SocketFd = int |
| using | rm::SSLContextRef = std::reference_wrapper<SSLContext> |
| SSL 上下文左值引用包装器 | |
枚举 | |
| enum class | rm::HTTPMethod : uint8_t { rm::HTTPMethod::Get , rm::HTTPMethod::Post , rm::HTTPMethod::Put , rm::HTTPMethod::Delete , rm::HTTPMethod::Patch , rm::HTTPMethod::Head , rm::HTTPMethod::Options , rm::HTTPMethod::Trace , rm::HTTPMethod::Connect , rm::HTTPMethod::Unknown } |
| HTTP 请求方法 更多... | |
| enum class | rm::NetworkInterfaceType : uint8_t { rm::NetworkInterfaceType::Ethernet , rm::NetworkInterfaceType::Wireless , rm::NetworkInterfaceType::PPP , rm::NetworkInterfaceType::Tunnel , rm::NetworkInterfaceType::Loopback , rm::NetworkInterfaceType::Other , rm::NetworkInterfaceType::Unknown } |
| 接口驱动类型 更多... | |
| enum class | rm::SSLMode { rm::SSLMode::Client , rm::SSLMode::Server } |
| TLS 工作模式 更多... | |
| enum class | rm::SSLVerifyMode { rm::SSLVerifyMode::None , rm::SSLVerifyMode::Peer } |
| TLS 证书验证方式 更多... | |
函数 | |
| URLParseInfo | rm::parseURL (std::string_view url) |
| 解析 URL | |
| std::tuple< std::string, bool > | rm::parseDNS (std::string_view hostname) |
| 域名解析 | |
| ResponseMiddleware | rm::statics (std::string_view url, std::string_view root) |
| 【中间件】静态路由,处理对指定 URL 路径的静态文件请求 | |
| ResponseMiddleware | rm::cors () |
| 【中间件】跨域资源共享 CORS,为响应添加 CORS 头部信息 | |
| Response | rm::requests::request (HTTPMethod method, std::string_view url, const std::vector< std::string > &querys={}, const std::unordered_map< std::string, std::string > &heads={}, std::string_view body="") |
| 发出同步 HTTP 请求 | |
| Response | rm::requests::get (std::string_view url, const std::vector< std::string > &querys={}, const std::unordered_map< std::string, std::string > &heads={}) |
| 发出同步 GET 请求 | |
| Response | rm::requests::post (std::string_view url, std::string_view body, const std::vector< std::string > &querys={}, const std::unordered_map< std::string, std::string > &heads={}) |
| 发出同步 POST 请求 | |
| Response | rm::requests::del (std::string_view url, const std::vector< std::string > &querys={}, const std::unordered_map< std::string, std::string > &heads={}) |
| 发出同步 DELETE 请求 | |
| Response | rm::requests::options (std::string_view url, const std::vector< std::string > &querys={}, const std::unordered_map< std::string, std::string > &heads={}) |
| 发出同步 OPTIONS 请求 | |
| Task< Response > | rm::async::requests::request (IOContext &io_context, HTTPMethod method, std::string_view url, const std::vector< std::string > &querys={}, const std::unordered_map< std::string, std::string > &heads={}, std::string_view body="") |
| 发出异步 HTTP 请求 | |
| Task< Response > | rm::async::requests::get (IOContext &io_context, std::string_view url, const std::vector< std::string > &querys={}, const std::unordered_map< std::string, std::string > &heads={}) |
| 发出异步 GET 请求 | |
| Task< Response > | rm::async::requests::post (IOContext &io_context, std::string_view url, std::string_view body, const std::vector< std::string > &querys={}, const std::unordered_map< std::string, std::string > &heads={}) |
| 发出异步 POST 请求 | |
| Task< Response > | rm::async::requests::del (IOContext &io_context, std::string_view url, const std::vector< std::string > &querys={}, const std::unordered_map< std::string, std::string > &heads={}) |
| 发出异步 DELETE 请求 | |
变量 | |
| constexpr SocketFd | rm::INVALID_SOCKET_FD = -1 |
提供跨平台的同步异步 Socket 通信、HTTP 请求、HTTP Web 后端框架功能
| using rm::ResponseMiddleware = std::function<void(const Request &, Response &)> |
#include <rmvl/io/netapp.hpp>
响应中间件类型
| using rm::SocketFd = int |
#include <rmvl/io/socket.hpp>
| using rm::SSLContextRef = std::reference_wrapper<SSLContext> |
#include <rmvl/io/ssl.hpp>
SSL 上下文左值引用包装器
|
strong |
#include <rmvl/io/netapp.hpp>
HTTP 请求方法
|
strong |
|
strong |
|
strong |
| ResponseMiddleware rm::cors | ( | ) |
#include <rmvl/io/netapp.hpp>
【中间件】跨域资源共享 CORS,为响应添加 CORS 头部信息
|
inline |
#include <rmvl/io/netapp.hpp>
发出异步 DELETE 请求
| [in] | io_context | 异步 I/O 执行上下文 |
| [in] | url | 请求的 URL |
| [in] | querys | 可选的 URL 参数列表 |
| [in] | heads | 可选的请求头列表 |
|
inline |
#include <rmvl/io/netapp.hpp>
发出同步 DELETE 请求
| [in] | url | 请求的 URL |
| [in] | querys | 可选的 URL 参数列表 |
| [in] | heads | 可选的请求头列表 |
|
inline |
#include <rmvl/io/netapp.hpp>
发出异步 GET 请求
| [in] | io_context | 异步 I/O 执行上下文 |
| [in] | url | 请求的 URL |
| [in] | querys | 可选的 URL 参数列表 |
| [in] | heads | 可选的请求头列表 |
|
inline |
#include <rmvl/io/netapp.hpp>
发出同步 GET 请求
| [in] | url | 请求的 URL |
| [in] | querys | 可选的 URL 参数列表 |
| [in] | heads | 可选的请求头列表 |
|
inline |
#include <rmvl/io/netapp.hpp>
发出同步 OPTIONS 请求
| [in] | url | 请求的 URL |
| [in] | querys | 可选的 URL 参数列表 |
| [in] | heads | 可选的请求头列表 |
| std::tuple< std::string, bool > rm::parseDNS | ( | std::string_view | hostname | ) |
| URLParseInfo rm::parseURL | ( | std::string_view | url | ) |
#include <rmvl/io/netapp.hpp>
解析 URL
| [in] | url | 统一资源定位符,例如 http://example.com:8080/path |
| scheme | 协议部分,例如 http 或 https |
| hostname | 域名部分,例如 example.com |
| port | 端口号,默认为 80 (HTTP) 或 443 (HTTPS) |
| path | 路径部分,例如 /path/to/resource |
| querys | 以 std::vector 存储的查询参数部分,例如 [key=value, key2=value2] |
|
inline |
#include <rmvl/io/netapp.hpp>
发出异步 POST 请求
| [in] | io_context | 异步 I/O 执行上下文 |
| [in] | url | 请求的 URL |
| [in] | body | 请求体 |
| [in] | querys | 可选的 URL 参数列表 |
| [in] | heads | 可选的请求头列表 |
|
inline |
#include <rmvl/io/netapp.hpp>
发出同步 POST 请求
| [in] | url | 请求的 URL |
| [in] | body | 请求体 |
| [in] | querys | 可选的 URL 参数列表 |
| [in] | heads | 可选的请求头列表 |
| Task< Response > rm::async::requests::request | ( | IOContext & | io_context, |
| HTTPMethod | method, | ||
| std::string_view | url, | ||
| const std::vector< std::string > & | querys = {}, | ||
| const std::unordered_map< std::string, std::string > & | heads = {}, | ||
| std::string_view | body = "" ) |
#include <rmvl/io/netapp.hpp>
发出异步 HTTP 请求
| [in] | io_context | 异步 I/O 执行上下文 |
| [in] | method | 请求方法 |
| [in] | url | 请求的 URL |
| [in] | querys | 可选的 URL 参数列表 |
| [in] | heads | 可选的请求头列表 |
| [in] | body | 可选的请求体 |
| Response rm::requests::request | ( | HTTPMethod | method, |
| std::string_view | url, | ||
| const std::vector< std::string > & | querys = {}, | ||
| const std::unordered_map< std::string, std::string > & | heads = {}, | ||
| std::string_view | body = "" ) |
#include <rmvl/io/netapp.hpp>
发出同步 HTTP 请求
| [in] | method | 请求方法 |
| [in] | url | 请求的 URL |
| [in] | querys | 可选的 URL 查询参数列表 |
| [in] | heads | 可选的请求头列表 |
| [in] | body | 可选的请求体 |
| ResponseMiddleware rm::statics | ( | std::string_view | url, |
| std::string_view | root ) |
#include <rmvl/io/netapp.hpp>
【中间件】静态路由,处理对指定 URL 路径的静态文件请求
| [in] | url | URL 路径前缀,例如 /static |
| [in] | root | 静态文件根目录,例如 ./public |
|
constexpr |
#include <rmvl/io/socket.hpp>