fn handle_connection(mut stream: TcpStream, server_files: ServerFiles, stats: Arc<ServerStats>) -> Option<(u32, String)> {
    let mut buffer = [0; 2048];

    if let Err(_) = stream.read(&mut buffer) {
        println!("Threaded: Error while processing request. Ignoring request");
        return None
    }

    let request = match parse_request(buffer.to_vec()) {
        Ok(req) => req,
        Err(e) => {
            send_response(stream, &mut error_response_400(format!("{}", e), server_files.dynamic_files));
            return None
        }
    };

    let mut response = handle_request(&request, server_files, stats);

    send_response(stream, &mut response);
    Some((response.response_identifiers.method.id, request.request_identifiers.path))
}
/// Handles a single connection.
/// Checking the request of correctness and returning the requested file
Handles a single connection.
Checking the request of correctness and returning the requested file
Handles a single connection . Checking the request of correctness and returning the requested file
fn handle_connection(mut stream: TcpStream, server_files: ServerFiles, stats: Arc<ServerStats>) -> Option<(u32, String)> {
    let mut buffer = [0; 2048];
    if let Err(_) = stream.read(&mut buffer) {
        println!("Threaded: Error while processing request. Ignoring request");
        return None
    }
    let request = match parse_request(buffer.to_vec()) {
        Ok(req) => req,
        Err(e) => {
            send_response(stream, &mut error_response_400(format!("{}", e), server_files.dynamic_files));
            return None
        }
    };
    let mut response = handle_request(&request, server_files, stats);
    send_response(stream, &mut response);
    Some((response.response_identifiers.method.id, request.request_identifiers.path))
}
fn handle_connection ( mut stream : TcpStream , server_files : ServerFiles , stats : Arc < ServerStats > ) -> Option < ( u32 , String ) > { let mut buffer = [ 0 ; 2048 ] ; if let Err ( _ ) = stream . read ( & mut buffer ) { println ! ( " " ) ; return None } let request = match parse_request ( buffer . to_vec ( ) ) { Ok ( req ) => req , Err ( e ) => { send_response ( stream , & mut error_response_400 ( format ! ( " " e ) , server_files . dynamic_files ) ) ; return None } } ; let mut response = handle_request ( & request , server_files , stats ) ; send_response ( stream , & mut response ) ; Some ( ( response . response_identifiers . method . id , request . request_identifiers . path ) ) }
Handles a single connection.
Handles a single connection .
stream
TcpStream
server_files
ServerFiles
stats
Arc<ServerStats>
stream
TcpStream
server_files
ServerFiles
stats
Arc<ServerStats>