/// Perform a connection. Does not follow redirects.
Perform a connection. Does not follow redirects.
Perform a connection . Does not follow redirects .
fn connect_inner(
    unit: &Unit,
    previous: &[Url],
) -> Result<Response, Error> {
    let host = unit
        .url
        .host_str()
        // This unwrap is ok because Request::parse_url() ensure there is always a host present.
        .unwrap();
    // open socket
    let stream = connect_socket(unit, host)?;
    let mut buf_stream = BufWriter::new(stream);
    let send_result = send_prelude(unit, &mut buf_stream, !previous.is_empty());
    if let Err(err) = send_result {
        // not a pooled connection, propagate the error.
        return Err(err.into());
    }
    // start reading the response to process cookies and redirects.
    let stream = buf_stream.into_inner().unwrap();
    let result = Response::do_from_request(unit.clone(), stream);
    // https://tools.ietf.org/html/rfc7230#section-6.3.1
    // When an inbound connection is closed prematurely, a client MAY
    // open a new connection and automatically retransmit an aborted
    // sequence of requests if all of those requests have idempotent
    // methods.
    //
    // We choose to retry only requests that used a recycled connection
    // from the ConnectionPool, since those are most likely to have
    // reached a server-side timeout. Note that this means we may do
    // up to N+1 total tries, where N is max_idle_connections_per_host.
    let resp = match result {
        Err(e) => return Err(e),
        Ok(resp) => resp,
    };
    // release the response
    Ok(resp)
}
fn connect_inner ( unit : & Unit , previous : & [ Url ] , ) -> Result < Response , Error > { let host = unit . url . host_str ( ) // This unwrap is ok because Request::parse_url() ensure there is always a host present. . unwrap ( ) ; // open socket let stream = connect_socket ( unit , host ) ? ; let mut buf_stream = BufWriter :: new ( stream ) ; let send_result = send_prelude ( unit , & mut buf_stream , ! previous . is_empty ( ) ) ; if let Err ( err ) = send_result { // not a pooled connection, propagate the error. return Err ( err . into ( ) ) ; } // start reading the response to process cookies and redirects. let stream = buf_stream . into_inner ( ) . unwrap ( ) ; let result = Response :: do_from_request ( unit . clone ( ) , stream ) ; // https://tools.ietf.org/html/rfc7230#section-6.3.1 // When an inbound connection is closed prematurely, a client MAY // open a new connection and automatically retransmit an aborted // sequence of requests if all of those requests have idempotent // methods. // // We choose to retry only requests that used a recycled connection // from the ConnectionPool, since those are most likely to have // reached a server-side timeout. Note that this means we may do // up to N+1 total tries, where N is max_idle_connections_per_host. let resp = match result { Err ( e ) => return Err ( e ) , Ok ( resp ) => resp , } ; // release the response Ok ( resp ) }
Perform a connection.
Perform a connection .
unit
&Unit
previous
&[Url]