Commit f7d07d0d authored by Nugine's avatar Nugine
Browse files

style: refactor HeaderValue usage

parent 719f784b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ use aws_sdk_s3::operation::{RequestId, RequestIdExt};
use hyper::HeaderMap;
use hyper::header::HeaderValue;

pub fn build_headers<T>(output: &T) -> S3Result<HeaderMap<HeaderValue>>
pub fn build_headers<T>(output: &T) -> S3Result<HeaderMap>
where
    T: RequestId + RequestIdExt,
{
+1 −2
Original line number Diff line number Diff line
use bytes::Bytes;
use http::HeaderValue;
use http::header::InvalidHeaderValue;
use stdx::str::StrExt;
@@ -135,7 +134,7 @@ impl ETag {
                buf
            }
        };
        HeaderValue::from_maybe_shared(Bytes::from(buf))
        HeaderValue::try_from(buf)
    }
}

+3 −3
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ pub struct AwsChunkedStream {
    remaining_length: usize,

    // Parsed trailing headers (lower-cased names) if present and verified.
    trailers: Arc<Mutex<Option<HeaderMap<HeaderValue>>>>,
    trailers: Arc<Mutex<Option<HeaderMap>>>,
}

impl Debug for AwsChunkedStream {
@@ -139,7 +139,7 @@ impl AwsChunkedStream {
    where
        S: Stream<Item = Result<Bytes, StdError>> + Send + Sync + 'static,
    {
        let trailers: Arc<Mutex<Option<HeaderMap<HeaderValue>>>> = Arc::new(Mutex::new(None));
        let trailers: Arc<Mutex<Option<HeaderMap>>> = Arc::new(Mutex::new(None));
        let trailers_for_worker = Arc::clone(&trailers);
        let inner = AsyncTryStream::<_, _, SyncBoxFuture<'static, Result<(), AwsChunkedStreamError>>>::new(|mut y| {
            #[allow(clippy::shadow_same)] // necessary for `pin_mut!`
@@ -206,7 +206,7 @@ impl AwsChunkedStream {
                                // However, if there are remaining bytes, we will just attempt to continue parsing
                                // which will likely fail with FormatError.
                                // Build HeaderMap from entries and store.
                                let mut map: HeaderMap<HeaderValue> = HeaderMap::new();
                                let mut map: HeaderMap = HeaderMap::new();
                                for (name, value) in entries {
                                    // Names are already lower-cased ASCII
                                    let hn: HeaderName = match name.parse() {
+1 −2
Original line number Diff line number Diff line
@@ -2,7 +2,6 @@

use hyper::HeaderMap;
use hyper::header::ToStrError;
use hyper::http::HeaderValue;

use crate::utils::stable_sort_by_first;

@@ -35,7 +34,7 @@ impl<'a> OrderedHeaders<'a> {
    ///
    /// # Errors
    /// Returns [`ToStrError`] if header value cannot be converted to string slice
    pub fn from_headers(map: &'a HeaderMap<HeaderValue>) -> Result<Self, ToStrError> {
    pub fn from_headers(map: &'a HeaderMap) -> Result<Self, ToStrError> {
        let mut headers: Vec<(&'a str, &'a str)> = Vec::with_capacity(map.len());

        for (name, value) in map {
+1 −2
Original line number Diff line number Diff line
@@ -12,13 +12,12 @@ use hyper::HeaderMap;
use hyper::Method;
use hyper::Uri;
use hyper::http::Extensions;
use hyper::http::HeaderValue;

pub struct Request {
    pub version: http::Version,
    pub method: Method,
    pub uri: Uri,
    pub headers: HeaderMap<HeaderValue>,
    pub headers: HeaderMap,
    pub extensions: Extensions,
    pub body: Body,
    pub(crate) s3ext: S3Extensions,
Loading