fn header(&mut self, data: &[u8]) -> bool {
        // 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.version = Some(version);
            self.status_code = Some(status);
            return true;
        }

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

        // Is this the end of the response header?
        if data == b"\r\n" {
            self.finalize_headers();
            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 request header.
Gets called by curl for each line of data in the HTTP request header.
Gets called by curl for each line of data in the HTTP request header .
fn header(&mut self, data: &[u8]) -> bool {
        // 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.version = Some(version);
            self.status_code = Some(status);
            return true;
        }
        // Is this a header line?
        if let Some((name, value)) = parse::parse_header(data) {
            self.headers.insert(name, value);
            return true;
        }
        // Is this the end of the response header?
        if data == b"\r\n" {
            self.finalize_headers();
            return true;
        }
        // Unknown header line we don't know how to parse.
        false
    }
fn header ( & mut self , data : & [ u8 ] ) -> bool { // 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 . version = Some ( version ) ; self . status_code = Some ( status ) ; return true ; } // Is this a header line? if let Some ( ( name , value ) ) = parse :: parse_header ( data ) { self . headers . insert ( name , value ) ; return true ; } // Is this the end of the response header? if data == b" \r \n " { self . finalize_headers ( ) ; 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 request header.
Gets called by curl for each line of data in the HTTP request header .
&mut self
data
&[u8]
&mut self
data
&[u8]