docs: 补充核心分层中文注释
This commit is contained in:
@@ -406,6 +406,7 @@ static const char *dns_error_name(int err)
|
||||
|
||||
static esp_err_t parse_url_host(const char *url, char *host, size_t host_capacity)
|
||||
{
|
||||
/* 仅提取 DNS 主机部分,同时兼容带方括号的 IPv6 字面量。 */
|
||||
if (url == NULL || host == NULL || host_capacity == 0U) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
@@ -446,6 +447,7 @@ static esp_err_t parse_url_host(const char *url, char *host, size_t host_capacit
|
||||
|
||||
static esp_err_t resolve_host_before_open(const char *url)
|
||||
{
|
||||
/* 在创建 HTTP client 前显式解析 DNS,便于提供稳定错误码和网络诊断。 */
|
||||
char host[PLATFORM_HTTPS_HOST_MAX_LEN];
|
||||
esp_err_t err = parse_url_host(url, host, sizeof(host));
|
||||
if (err != ESP_OK) {
|
||||
@@ -528,6 +530,7 @@ static esp_err_t resolve_host_before_open(const char *url)
|
||||
|
||||
static esp_err_t write_all(esp_http_client_handle_t client, const char *payload)
|
||||
{
|
||||
/* esp_http_client_write 允许短写,循环直到完整 payload 发出或明确失败。 */
|
||||
size_t payload_len = strlen(payload);
|
||||
if (payload_len > (size_t)INT_MAX) {
|
||||
return ESP_ERR_INVALID_SIZE;
|
||||
@@ -551,6 +554,7 @@ static esp_err_t write_all(esp_http_client_handle_t client, const char *payload)
|
||||
esp_err_t platform_https_post_json(const platform_https_post_json_request_t *request,
|
||||
platform_https_response_t *response)
|
||||
{
|
||||
/* 先清空调用方响应快照,确保任何提前失败都不会暴露上次请求的旧数据。 */
|
||||
if (response != NULL) {
|
||||
response->body_len = 0U;
|
||||
response->status_code = -1;
|
||||
|
||||
Reference in New Issue
Block a user