/* SPDX-License-Identifier: GPL-3.0-only */ #pragma once #include "esp_http_server.h" #include #define WEB_HTTPD_IDLE_SOCKETS 6U #define WEB_HTTPD_IDLE_TIMEOUT_US INT64_C(15000000) typedef struct { uint64_t completed; int64_t idle_since_us; int fd; bool observed, shutdown_sent; } web_httpd_idle_row_t; /* HTTPD-owner work boundary only. TLS create must invalidate reused fd rows. */ void web_httpd_idle_sweep(httpd_handle_t server, web_httpd_idle_row_t rows[WEB_HTTPD_IDLE_SOCKETS], int64_t now); /* HTTPD-owner only, before body reads or any response. Reject duplicate lines, * including Cookie, rather than trusting first-match public getters. */ bool web_httpd_headers_valid(httpd_req_t *request); bool web_httpd_upgrade_requested(httpd_req_t *request); bool web_httpd_unread_body(httpd_req_t *request); /* After the final response/lookup: preserve only unread pipelined data on a * keepalive connection. Closing requests may discard pending data entirely. */ void web_httpd_wipe_request(httpd_req_t *request, bool closing); esp_err_t web_httpd_upgrade(httpd_req_t *request, esp_err_t (*handler)(httpd_req_t *)); /* Serialized server startup only, exact-match ordinary GET, URI <= 127 bytes. * Stage both allocations before publication; HTTPD owns/frees them on success. */ esp_err_t web_httpd_register_optional_get(httpd_handle_t server, const httpd_uri_t *uri); /* Same staged startup ownership for ordinary exact GET or POST. */ esp_err_t web_httpd_register_optional(httpd_handle_t server, const httpd_uri_t *uri);