Archived
3
0

Create build system (#1)

This commit is contained in:
Matěj Žucha
2025-03-09 18:22:14 +00:00
committed by Ondřej Mekina
parent 5bb655b7de
commit 77c8deabc8
36 changed files with 1860 additions and 478 deletions

View File

@@ -158,6 +158,14 @@ impl HeaderValue {
self.inner.push(val);
}
/// Create a new unchecked value.
/// This is faster, but can cause protocol violation.
/// Please avoid putting unchecked content here.
#[inline]
pub fn new_unchecked(inner: String) -> Self {
Self { inner: vec![inner] }
}
/// Query the first entry for this header key.
///
/// See the documentation of [`HeaderValue`] for more information.

View File

@@ -1,3 +1,5 @@
#![allow(dead_code)]
pub mod settings;
mod io;

View File

@@ -322,6 +322,28 @@ pub enum Request<'a, T> {
WithChunkedBody((RequestHead, Incoming<'a, ChunkedIn<'a, PrependableStream<T>>>)),
}
impl<T> Response<'_, T> {
#[inline]
pub fn head(&self) -> &ResponseHead {
match self {
Self::HeadersOnly(h) => h,
Self::WithSizedBody((h, _)) => h,
Self::WithChunkedBody((h, _)) => h,
}
}
}
impl<T> Request<'_, T> {
#[inline]
pub fn head(&self) -> &RequestHead {
match self {
Self::HeadersOnly(h) => h,
Self::WithSizedBody((h, _)) => h,
Self::WithChunkedBody((h, _)) => h,
}
}
}
fn get_outgoing_req_content_length(head: &RequestHead) -> Result<Option<usize>, ClientSendError> {
let Some(l) = head.headers.get(&HeaderKey::CONTENT_LENGTH) else {
return Ok(None);