fn default_headers(request: &mut super::request::Request) {
        Self::default_user_agent(request);

        if !request.headers().contains_key(header::HOST) {
            let host = request.uri().host().and_then(|host| match request.uri().port().map(|port| port.as_u16()) {
                None | Some(80) | Some(443) => header::HeaderValue::from_str(host).ok(),
                Some(port) => {
                    let mut buffer = utils::BytesWriter::with_capacity(host.len() + 5);
                    let _ = write!(&mut buffer, "{}:{}", host, port);

                    http::header::HeaderValue::from_maybe_shared(buffer.freeze()).ok()
                },
            });

            if let Some(host) = host {
                request.headers_mut().insert(header::HOST, host);
            }
        }
    }
///Allows to sets default headers before request
///is sent out
///
///It is called as soon as request is being sent out,
///but before `Accept-Encoding` is set.
///
///By default it sets following, if not present:
///
///- Set default user agent;
///- `HOST` header with host, and optionally port, taken from URI;
Allows to sets default headers before request
is sent out

It is called as soon as request is being sent out,
but before `Accept-Encoding` is set.

By default it sets following, if not present.

Set default user agent;
`HOST` header with host, and optionally port, taken from URI.
Allows to sets default headers before request is sent out It is called as soon as request is being sent out but before ` Accept - Encoding ` is set . By default it sets following if not present . Set default user agent ; ` HOST ` header with host and optionally port taken from URI .
fn default_headers(request: &mut super::request::Request) {
        Self::default_user_agent(request);
        if !request.headers().contains_key(header::HOST) {
            let host = request.uri().host().and_then(|host| match request.uri().port().map(|port| port.as_u16()) {
                None | Some(80) | Some(443) => header::HeaderValue::from_str(host).ok(),
                Some(port) => {
                    let mut buffer = utils::BytesWriter::with_capacity(host.len() + 5);
                    let _ = write!(&mut buffer, "{}:{}", host, port);
                    http::header::HeaderValue::from_maybe_shared(buffer.freeze()).ok()
                },
            });
            if let Some(host) = host {
                request.headers_mut().insert(header::HOST, host);
            }
        }
    }
fn default_headers ( request : & mut super :: request :: Request ) { Self :: default_user_agent ( request ) ; if ! request . headers ( ) . contains_key ( header :: HOST ) { let host = request . uri ( ) . host ( ) . and_then ( | host | match request . uri ( ) . port ( ) . map ( | port | port . as_u16 ( ) ) { None | Some ( 80 ) | Some ( 443 ) => header :: HeaderValue :: from_str ( host ) . ok ( ) , Some ( port ) => { let mut buffer = utils :: BytesWriter :: with_capacity ( host . len ( ) + 5 ) ; let _ = write ! ( mut buffer " " host port ) ; http :: header :: HeaderValue :: from_maybe_shared ( buffer . freeze ( ) ) . ok ( ) } , } ) ; if let Some ( host ) = host { request . headers_mut ( ) . insert ( header :: HOST , host ) ; } } }
Allows to sets default headers before request
is sent out
Allows to sets default headers before request is sent out
request
&mut super::request::Request