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
pub use http::response::{Builder as ResponseBuilder, Parts as ResponseHead};

use super::BorrowHeaderMap;
use crate::{
    common::{FromParts, IntoParts},
    h1::payload::Payload,
};

pub type Response<P = Payload> = http::response::Response<P>;

impl<P> FromParts<ResponseHead, P> for Response<P> {
    #[inline]
    fn from_parts(parts: ResponseHead, body: P) -> Self {
        Self::from_parts(parts, body)
    }
}

impl<P> IntoParts for Response<P> {
    type Parts = ResponseHead;
    type Body = P;
    #[inline]
    fn into_parts(self) -> (Self::Parts, Self::Body) {
        self.into_parts()
    }
}

pub struct ResponseHeadRef<'a> {
    pub status: http::StatusCode,
    pub version: http::Version,
    pub headers: &'a http::HeaderMap<http::HeaderValue>,
    pub extensions: &'a http::Extensions,
}

impl BorrowHeaderMap for ResponseHead {
    #[inline]
    fn header_map(&self) -> &http::HeaderMap {
        &self.headers
    }
}