|
DeterministicESPAsyncWebServer 1.2.0
Zero-allocation, bounded-execution async HTTP server for ESP32
|
Standalone HTTP/1.1 request parser — implementation. More...
#include "http_parser.h"Go to the source code of this file.
Functions | |
| void | http_parser_reset (HttpReq *req) |
| Reset a parser context to the initial (PARSE_METHOD) state. | |
| void | http_parser_feed (HttpReq *p, uint8_t byte) |
| Feed one byte to the parser state machine. | |
| const char * | http_get_header (const HttpReq *req, const char *key) |
| Look up a header value by name (case-insensitive). | |
| const char * | http_get_query (const HttpReq *req, const char *key) |
| Look up a query parameter value by name (case-sensitive). | |
Variables | |
| HttpReq | http_pool [MAX_CONNS] |
| Pool of parser contexts, one per transport slot. | |
Standalone HTTP/1.1 request parser — implementation.
No dependency on transport, session, or lwIP. Consumes one byte at a time via http_parser_feed(); the presentation layer is responsible for pulling bytes out of whatever transport buffer it uses.
Definition in file http_parser.cpp.
| void http_parser_reset | ( | HttpReq * | req | ) |
Reset a parser context to the initial (PARSE_METHOD) state.
Zeroes all fields and sets parse_state = PARSE_METHOD. Call before the first use, after each completed or failed request, and on connection events.
| req | Parser context to reset. Must not be null. |
Definition at line 150 of file http_parser.cpp.
References HttpReq::_version_hash, PARSE_METHOD, HttpReq::parse_state, and HttpReq::slot_id.
Referenced by http_reset().
| void http_parser_feed | ( | HttpReq * | req, |
| uint8_t | byte | ||
| ) |
Feed one byte to the parser state machine.
Returns immediately without modifying state when parse_state is already PARSE_COMPLETE, PARSE_ERROR, PARSE_ENTITY_TOO_LARGE, or PARSE_URI_TOO_LONG.
| req | Parser context for this request. |
| byte | Next byte from the HTTP stream. |
Definition at line 159 of file http_parser.cpp.
References HttpReq::_version_hash, HttpReq::body, BODY_BUF_SIZE, HttpReq::body_bytes_read, HttpReq::body_len, HttpReq::content_length, HttpReq::current_token_idx, HttpReq::header_count, HttpReq::headers, HTTP_10, HTTP_11, HTTP_UNKNOWN, Header::key, MAX_HEADERS, MAX_KEY_LEN, MAX_PATH_LEN, MAX_QUERY_LEN, MAX_VAL_LEN, HttpReq::method, PARSE_BODY, PARSE_COMPLETE, PARSE_ENTITY_TOO_LARGE, PARSE_ERROR, PARSE_EXPECT_BODY_LF, PARSE_EXPECT_LF, PARSE_HEADER_KEY, PARSE_HEADER_VAL, PARSE_METHOD, PARSE_PATH, PARSE_QUERY, HttpReq::parse_state, PARSE_URI_TOO_LONG, PARSE_VERSION, HttpReq::path, HttpReq::path_idx, HttpReq::query, HttpReq::query_idx, Header::val, and HttpReq::version.
Referenced by http_parse().
| const char * http_get_header | ( | const HttpReq * | req, |
| const char * | key | ||
| ) |
Look up a header value by name (case-insensitive).
| req | Parsed request. |
| key | Header field name (e.g. "Content-Type"). |
nullptr if not found. Definition at line 389 of file http_parser.cpp.
References HttpReq::header_count, HttpReq::headers, Header::key, and Header::val.
Referenced by multipart_parse().
| const char * http_get_query | ( | const HttpReq * | req, |
| const char * | key | ||
| ) |
Look up a query parameter value by name (case-sensitive).
| req | Parsed request. |
| key | Parameter name. |
key= with no value), or nullptr if the key is absent. Definition at line 399 of file http_parser.cpp.
References QueryParam::key, HttpReq::query_count, HttpReq::query_params, and QueryParam::val.
Pool of parser contexts, one per transport slot.
Definition at line 15 of file http_parser.cpp.
Referenced by DetWebServer::handle(), http_parse(), and http_reset().