rama_http_types/
conn.rs

1//! HTTP connection utilities.
2
3use serde::{Deserialize, Serialize};
4
5use crate::proto::h2::{
6    PseudoHeaderOrder,
7    frame::{SettingsConfig, StreamId},
8};
9
10#[derive(Debug, Clone, Default)]
11/// Optional parameters that can be set in the [`Context`] of a (h1) request
12/// to customise the connection of the h1 connection.
13///
14/// Can be used by Http connector services, especially in the context of proxies,
15/// where there might not be one static config that is to be applied to all client connections.
16pub struct Http1ClientContextParams {
17    /// Set whether HTTP/1 connections will write header names as title case at
18    /// the socket level.
19    ///
20    /// Default is false.
21    pub title_header_case: bool,
22}
23
24#[derive(Debug, Clone, Default)]
25/// Optional parameters that can be set in the [`Context`] of a (h2) request
26/// to customise the connection of the h2 connection.
27///
28/// Can be used by Http connector services, especially in the context of proxies,
29/// where there might not be one static config that is to be applied to all client connections.
30pub struct H2ClientContextParams {
31    /// Pseudo order of the headers stream
32    pub headers_pseudo_order: Option<PseudoHeaderOrder>,
33
34    /// Priority of the headers stream
35    pub headers_priority: Option<StreamDependencyParams>,
36
37    /// Priority stream list
38    pub priority: Option<Vec<PriorityParams>>,
39
40    /// Config for h2 settings
41    pub setting_config: Option<SettingsConfig>,
42}
43
44#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
45pub struct StreamDependencyParams {
46    /// The ID of the stream dependency target
47    pub dependency_id: StreamId,
48
49    /// The weight for the stream. The value exposed (and set) here is always in
50    /// the range [0, 255], instead of [1, 256] (as defined in section 5.3.2.)
51    /// so that the value fits into a `u8`.
52    pub weight: u8,
53
54    /// True if the stream dependency is exclusive.
55    pub is_exclusive: bool,
56}
57
58#[derive(Debug, Clone)]
59/// Injected into h2 requests for those who are interested in this.
60pub struct LastPeerPriorityParams(pub PriorityParams);
61
62#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
63pub struct PriorityParams {
64    pub stream_id: StreamId,
65    pub dependency: StreamDependencyParams,
66}