fn get_simple()

in http/get_simple/rs/server/src/main.rs [79:105]


fn get_simple(mut stream: std::net::TcpStream) {
    info!("Incoming connection");

    // Ignore incoming request.
    for _ in BufReader::new(&mut stream)
        .lines()
        .take_while(|line| line.as_ref().is_ok_and(|line| !line.is_empty()))
    {}

    // Write response header.
    stream
        .write_all(
            "HTTP/1.1 200 OK\r\ncontent-type: application/vnd.apache.arrow.stream\r\n\r\n"
                .as_bytes(),
        )
        .unwrap();

    // Stream the body.
    let mut writer = StreamWriter::try_new(stream, &SCHEMA).unwrap();
    for batch in DATA.iter() {
        writer.write(batch).unwrap();
    }
    writer.finish().unwrap();

    let stream = writer.into_inner().unwrap();
    stream.shutdown(std::net::Shutdown::Both).unwrap();
}