Skip to main content

rama_http_types/proto/
mod.rs

1//! High level pertaining to the HTTP message protocol.
2//!
3//! For low-level proto details you can refer to the `proto` module
4//! in the `rama-http-core` crate.
5
6use std::{ops::Deref, sync::Arc};
7
8use rama_core::extensions::Extension;
9
10use crate::HeaderMap;
11
12pub mod h1;
13pub mod h2;
14
15#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Extension)]
16#[extension(tags(http))]
17/// Byte length of the raw bytes of the request/response headers (excl. trailers).
18pub struct HeaderByteLength(pub usize);
19
20#[derive(Debug, Clone, Extension)]
21#[extension(tags(http))]
22/// Read-only copy of the parent request headers.
23///
24/// This extension can be made available in [`RequestHeaders`].
25pub struct RequestHeaders(Arc<HeaderMap>);
26
27impl From<HeaderMap> for RequestHeaders {
28    fn from(value: HeaderMap) -> Self {
29        Self(Arc::new(value))
30    }
31}
32
33impl Deref for RequestHeaders {
34    type Target = HeaderMap;
35
36    fn deref(&self) -> &Self::Target {
37        self.0.as_ref()
38    }
39}