1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// SPDX-License-Identifier: MIT OR Apache-2.0
// This file is part of Static Web Server.
// See https://static-web-server.net/ for more information
// Copyright (C) 2019-present Jose Quintana <joseluisq.net>
//! Unified HTTP response body type and constructor helpers.
//!
//! This module provides a single concrete body type alias and a small set of
//! constructor functions.
use Bytes;
use Frame;
use ;
use io;
/// Unified response body type used throughout the server.
///
/// A type-erased boxed body backed by [`http_body_util::combinators::BoxBody`]
/// with [`bytes::Bytes`] data frames and [`io::Error`] errors.
///
/// This single type covers all body variants used by the server:
/// - Empty bodies (for HEAD responses, OPTIONS, redirects)
/// - In-memory byte buffers (for generated HTML, Prometheus metrics, health checks)
/// - File streams ([`crate::fs::stream::FileStream`])
/// - Compressed streams (gzip/brotli/deflate/zstd encoders)
/// - In-memory cached file streams ([`crate::mem_cache::stream::MemCacheFileStream`])
pub type Body = ;
/// Creates an empty body (zero bytes).
///
/// Replaces `hyper::Body::empty()`.
/// Creates a full body from in-memory bytes.
///
/// Replaces `hyper::Body::from(x)` for byte buffers and strings.
/// Accepts anything that converts into [`Bytes`]: `String`, `Vec<u8>`, `&'static str`,
/// `&'static [u8]`, or `Bytes` directly.
/// Creates a streaming body from an async byte stream.
///
/// Replaces `hyper::Body::wrap_stream(s)`.
///
/// The stream must yield `Result<Bytes, io::Error>`. Each successful item is
/// wrapped as an HTTP data [`Frame`] before being fed into the body.