index : static-web-server.git

ascending towards madness

author Jose Quintana <joseluisquintana20@gmail.com> 2022-03-08 22:44:21.0 +00:00:00
committer Jose Quintana <joseluisquintana20@gmail.com> 2022-03-08 22:51:13.0 +00:00:00
commit
06cc3792299516f31e123462783392e2cb7b7f99 [patch]
tree
284d5d07a4b9819279c3a20dc98bdd0134618793
parent
d33d093a781174beb580bd97fdeadc0dafdde244
download
06cc3792299516f31e123462783392e2cb7b7f99.tar.gz

refactor: improvement creating encoding headers during compression



Diff

 src/compression.rs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/compression.rs b/src/compression.rs
index 9ddd677..2357d80 100644
--- a/src/compression.rs
+++ b/src/compression.rs
@@ -10,7 +10,6 @@ use hyper::{
    Body, Method, Response,
};
use pin_project::pin_project;
use std::convert::TryFrom;
use std::pin::Pin;
use std::task::{Context, Poll};
use tokio_util::io::{ReaderStream, StreamReader};
@@ -139,12 +138,13 @@ pub fn brotli(
fn create_encoding_header(existing: Option<HeaderValue>, coding: ContentCoding) -> HeaderValue {
    if let Some(val) = existing {
        if let Ok(str_val) = val.to_str() {
            return HeaderValue::try_from(&format!("{}, {}", str_val, coding.to_string()))
            return HeaderValue::from_str(&[str_val, ", ", coding.to_static()].concat())
                .unwrap_or_else(|_| coding.into());
        }
    }
    coding.into()
}

/// A wrapper around any type that implements [`Stream`](futures::Stream) to be
/// compatible with async_compression's Stream based encoders.
#[pin_project]
@@ -155,7 +155,7 @@ where
    E: std::error::Error,
{
    #[pin]
    pub body: S,
    body: S,
}

impl<S, E> Stream for CompressableBody<S, E>