DeterministicESPAsyncWebServer
v6.27.1
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
http_range.h
Go to the documentation of this file.
1
// Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2
// SPDX-License-Identifier: AGPL-3.0-or-later
3
4
/**
5
* @file http_range.h
6
* @brief Shared single-range `Range: bytes=...` parser (RFC 7233), used by static file serving and the
7
* edge cache (DETWS_ENABLE_RANGE).
8
*
9
* Promoted out of file_serving.cpp so both the filesystem file server and the CDN edge cache share one
10
* owner for the range math. Pure and size/string-driven - no DetWebServer or fs:: dependency.
11
*
12
* @author Douglas Quigg (dstroy0)
13
* @date 2026
14
*/
15
16
#ifndef DETERMINISTICESPASYNCWEBSERVER_HTTP_RANGE_H
17
#define DETERMINISTICESPASYNCWEBSERVER_HTTP_RANGE_H
18
19
#include "
ServerConfig.h
"
20
21
#if DETWS_ENABLE_RANGE
22
23
#include <stddef.h>
24
25
/**
26
* @brief Parse a single-range `Range: bytes=...` header value against a resource of @p size bytes.
27
*
28
* Supported forms: "bytes=A-B", "bytes=A-" (A to end), "bytes=-N" (last N bytes). A start past
29
* SIZE_MAX saturates (never wraps) so it resolves as past-EOF. @return:
30
* - 0 no usable Range header (caller sends a full 200) - absent, malformed, trailing garbage, or a
31
* multi-range request (RFC 7233 sec 3.1 permits ignoring it),
32
* - 1 a satisfiable range (writes the inclusive [*out_start, *out_end]),
33
* - -1 a syntactically valid but unsatisfiable range (caller sends 416).
34
*/
35
int
http_parse_byte_range(
const
char
*hdr,
size_t
size,
size_t
*out_start,
size_t
*out_end);
36
37
#endif
// DETWS_ENABLE_RANGE
38
39
#endif
// DETERMINISTICESPASYNCWEBSERVER_HTTP_RANGE_H
ServerConfig.h
User-facing configuration for DeterministicESPAsyncWebServer.
src
server
http_range.h
Generated by
1.9.8