fn header(&mut self, data: &[u8]) -> bool {
        // Abort the request if it has been canceled.
        if self.shared.future_dropped.load() {
            return false;
        }

        // Curl calls this function for all lines in the response not part of
        // the response body, not just for headers. We need to inspect the
        // contents of the string in order to determine what it is and how to
        // parse it, just as if we were reading from the socket of a HTTP/1.0 or
        // HTTP/1.1 connection ourselves.

        // Is this the status line?
        if let Some((version, status)) = parse::parse_status_line(data) {
            self.response_version = Some(version);
            self.response_status_code = Some(status);

            // Also clear any pre-existing headers that might be left over from
            // a previous intermediate response.
            self.response_headers.clear();

            return true;
        }

        // Is this a header line?
        if let Some((name, value)) = parse::parse_header(data) {
            self.response_headers.append(name, value);
            return true;
        }

        // Is this the end of the response header?
        if data == b"\r\n" {
            // We will acknowledge the end of the header, but we can't complete
            // our response future yet. If curl decides to follow a redirect,
            // then this current response is not the final response and not the
            // one we should complete with.
            //
            // Instead, we will complete the future when curl marks the transfer
            // as complete, or when we start receiving a response body.
            return true;
        }

        // Unknown header line we don't know how to parse.
        false
    }
/// Gets called by curl for each line of data in the HTTP response header.
Gets called by curl for each line of data in the HTTP response header.
Gets called by curl for each line of data in the HTTP response header .
fn header(&mut self, data: &[u8]) -> bool {
        // Abort the request if it has been canceled.
        if self.shared.future_dropped.load() {
            return false;
        }
        // Curl calls this function for all lines in the response not part of
        // the response body, not just for headers. We need to inspect the
        // contents of the string in order to determine what it is and how to
        // parse it, just as if we were reading from the socket of a HTTP/1.0 or
        // HTTP/1.1 connection ourselves.
        // Is this the status line?
        if let Some((version, status)) = parse::parse_status_line(data) {
            self.response_version = Some(version);
            self.response_status_code = Some(status);
            // Also clear any pre-existing headers that might be left over from
            // a previous intermediate response.
            self.response_headers.clear();
            return true;
        }
        // Is this a header line?
        if let Some((name, value)) = parse::parse_header(data) {
            self.response_headers.append(name, value);
            return true;
        }
        // Is this the end of the response header?
        if data == b"\r\n" {
            // We will acknowledge the end of the header, but we can't complete
            // our response future yet. If curl decides to follow a redirect,
            // then this current response is not the final response and not the
            // one we should complete with.
            //
            // Instead, we will complete the future when curl marks the transfer
            // as complete, or when we start receiving a response body.
            return true;
        }
        // Unknown header line we don't know how to parse.
        false
    }
fn header ( & mut self , data : & [ u8 ] ) -> bool { // Abort the request if it has been canceled. if self . shared . future_dropped . load ( ) { return false ; } // Curl calls this function for all lines in the response not part of // the response body, not just for headers. We need to inspect the // contents of the string in order to determine what it is and how to // parse it, just as if we were reading from the socket of a HTTP/1.0 or // HTTP/1.1 connection ourselves. // Is this the status line? if let Some ( ( version , status ) ) = parse :: parse_status_line ( data ) { self . response_version = Some ( version ) ; self . response_status_code = Some ( status ) ; // Also clear any pre-existing headers that might be left over from // a previous intermediate response. self . response_headers . clear ( ) ; return true ; } // Is this a header line? if let Some ( ( name , value ) ) = parse :: parse_header ( data ) { self . response_headers . append ( name , value ) ; return true ; } // Is this the end of the response header? if data == b" \r \n " { // We will acknowledge the end of the header, but we can't complete // our response future yet. If curl decides to follow a redirect, // then this current response is not the final response and not the // one we should complete with. // // Instead, we will complete the future when curl marks the transfer // as complete, or when we start receiving a response body. return true ; } // Unknown header line we don't know how to parse. false }
Gets called by curl for each line of data in the HTTP response header.
Gets called by curl for each line of data in the HTTP response header .
&mut self
data
&[u8]