fn prep_for_sending(#[allow(unused_mut)] mut self) -> Result<Self, PrepForSendingError> {
        if let Some(e) = self.err {
            return Err(e.into());
        }

        // validate uri
        let uri = &self.head.uri;
        if uri.host().is_none() {
            return Err(InvalidUrl::MissingHost.into());
        } else if uri.scheme().is_none() {
            return Err(InvalidUrl::MissingScheme.into());
        } else if let Some(scheme) = uri.scheme() {
            match scheme.as_str() {
                "http" | "ws" | "https" | "wss" => {}
                _ => return Err(InvalidUrl::UnknownScheme.into()),
            }
        } else {
            return Err(InvalidUrl::UnknownScheme.into());
        }

        // set cookies
        #[cfg(feature = "cookies")]
        if let Some(ref mut jar) = self.cookies {
            let cookie: String = jar
                .delta()
                // ensure only name=value is written to cookie header
                .map(|c| c.stripped().encoded().to_string())
                .collect::<Vec<_>>()
                .join("; ");

            if !cookie.is_empty() {
                self.head
                    .headers
                    .insert(header::COOKIE, HeaderValue::from_str(&cookie).unwrap());
            }
        }

        let mut slf = self;

        // Set Accept-Encoding HTTP header depending on enabled feature.
        // If decompress is not ask, then we are not able to find which encoding is
        // supported, so we cannot guess Accept-Encoding HTTP header.
        if slf.response_decompress {
            // Set Accept-Encoding with compression algorithm awc is built with.
            #[allow(clippy::vec_init_then_push)]
            #[cfg(feature = "__compress")]
            let accept_encoding = {
                let mut encoding = vec![];

                #[cfg(feature = "compress-brotli")]
                {
                    encoding.push("br");
                }

                #[cfg(feature = "compress-gzip")]
                {
                    encoding.push("gzip");
                    encoding.push("deflate");
                }

                #[cfg(feature = "compress-zstd")]
                encoding.push("zstd");

                assert!(
                    !encoding.is_empty(),
                    "encoding can not be empty unless __compress feature has been explicitly enabled"
                );

                encoding.join(", ")
            };

            // Otherwise tell the server, we do not support any compression algorithm.
            // So we clearly indicate that we do want identity encoding.
            #[cfg(not(feature = "__compress"))]
            let accept_encoding = "identity";

            slf = slf.insert_header_if_none((header::ACCEPT_ENCODING, accept_encoding));
        }

        Ok(slf)
    }
// allow unused mut when cookies feature is disabled
allow unused mut when cookies feature is disabled
allow unused mut when cookies feature is disabled
fn prep_for_sending(#[allow(unused_mut)] mut self) -> Result<Self, PrepForSendingError> {
        if let Some(e) = self.err {
            return Err(e.into());
        }
        // validate uri
        let uri = &self.head.uri;
        if uri.host().is_none() {
            return Err(InvalidUrl::MissingHost.into());
        } else if uri.scheme().is_none() {
            return Err(InvalidUrl::MissingScheme.into());
        } else if let Some(scheme) = uri.scheme() {
            match scheme.as_str() {
                "http" | "ws" | "https" | "wss" => {}
                _ => return Err(InvalidUrl::UnknownScheme.into()),
            }
        } else {
            return Err(InvalidUrl::UnknownScheme.into());
        }
        // set cookies
        #[cfg(feature = "cookies")]
        if let Some(ref mut jar) = self.cookies {
            let cookie: String = jar
                .delta()
                // ensure only name=value is written to cookie header
                .map(|c| c.stripped().encoded().to_string())
                .collect::<Vec<_>>()
                .join("; ");
            if !cookie.is_empty() {
                self.head
                    .headers
                    .insert(header::COOKIE, HeaderValue::from_str(&cookie).unwrap());
            }
        }
        let mut slf = self;
        // Set Accept-Encoding HTTP header depending on enabled feature.
        // If decompress is not ask, then we are not able to find which encoding is
        // supported, so we cannot guess Accept-Encoding HTTP header.
        if slf.response_decompress {
            // Set Accept-Encoding with compression algorithm awc is built with.
            #[allow(clippy::vec_init_then_push)]
            #[cfg(feature = "__compress")]
            let accept_encoding = {
                let mut encoding = vec![];
                #[cfg(feature = "compress-brotli")]
                {
                    encoding.push("br");
                }
                #[cfg(feature = "compress-gzip")]
                {
                    encoding.push("gzip");
                    encoding.push("deflate");
                }
                #[cfg(feature = "compress-zstd")]
                encoding.push("zstd");
                assert!(
                    !encoding.is_empty(),
                    "encoding can not be empty unless __compress feature has been explicitly enabled"
                );
                encoding.join(", ")
            };
            // Otherwise tell the server, we do not support any compression algorithm.
            // So we clearly indicate that we do want identity encoding.
            #[cfg(not(feature = "__compress"))]
            let accept_encoding = "identity";
            slf = slf.insert_header_if_none((header::ACCEPT_ENCODING, accept_encoding));
        }
        Ok(slf)
    }
fn prep_for_sending ( # [ allow ( unused_mut ) ] mut self ) -> Result < Self , PrepForSendingError > { if let Some ( e ) = self . err { return Err ( e . into ( ) ) ; } // validate uri let uri = & self . head . uri ; if uri . host ( ) . is_none ( ) { return Err ( InvalidUrl :: MissingHost . into ( ) ) ; } else if uri . scheme ( ) . is_none ( ) { return Err ( InvalidUrl :: MissingScheme . into ( ) ) ; } else if let Some ( scheme ) = uri . scheme ( ) { match scheme . as_str ( ) { " " | " " | " " | " " => { } _ => return Err ( InvalidUrl :: UnknownScheme . into ( ) ) , } } else { return Err ( InvalidUrl :: UnknownScheme . into ( ) ) ; } // set cookies # [ cfg ( feature " " ) ] if let Some ( ref mut jar ) = self . cookies { let cookie : String = jar . delta ( ) // ensure only name=value is written to cookie header . map ( | c | c . stripped ( ) . encoded ( ) . to_string ( ) ) . collect :: < Vec < _ > > ( ) . join ( " " ) ; if ! cookie . is_empty ( ) { self . head . headers . insert ( header :: COOKIE , HeaderValue :: from_str ( & cookie ) . unwrap ( ) ) ; } } let mut slf = self ; // Set Accept-Encoding HTTP header depending on enabled feature. // If decompress is not ask, then we are not able to find which encoding is // supported, so we cannot guess Accept-Encoding HTTP header. if slf . response_decompress { // Set Accept-Encoding with compression algorithm awc is built with. # [ allow ( clippy vec_init_then_push ) ] # [ cfg ( feature " " ) ] let accept_encoding = { let mut encoding = vec ! [ ] ; # [ cfg ( feature " " ) ] { encoding . push ( " " ) ; } # [ cfg ( feature " " ) ] { encoding . push ( " " ) ; encoding . push ( " " ) ; } # [ cfg ( feature " " ) ] encoding . push ( " " ) ; assert ! ( encoding is_empty ( ) " " ) ; encoding . join ( " " ) } ; // Otherwise tell the server, we do not support any compression algorithm. // So we clearly indicate that we do want identity encoding. # [ cfg ( not ( feature " " ) ) ] let accept_encoding = " " ; slf = slf . insert_header_if_none ( ( header :: ACCEPT_ENCODING , accept_encoding ) ) ; } Ok ( slf ) }
allow unused mut when cookies feature is disabled
allow unused mut when cookies feature is disabled
mut self
mut self