diff --git a/src/connection.rs b/src/connection.rs index 141b96c..de45de3 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -4,7 +4,7 @@ use std::collections::VecDeque; use std::fs::File; use std::io::{Read, Write}; -use std::os::unix::io::AsRawFd; +use std::os::unix::io::RawFd; use crate::common::ascii::{CR, CRLF_LEN, LF}; use crate::common::Body; @@ -56,8 +56,8 @@ pub struct HttpConnection { /// The latest file that has been received and which must be associated /// with the pending request. rx_file: Option, - /// The enqueued file that should be sent with contents of `response_buffer`. - tx_file: Option, + /// The enqueued file descriptor that should be sent with contents of `response_buffer`. + tx_file: Option, /// Optional payload max size. payload_max_size: usize, } @@ -441,9 +441,9 @@ impl HttpConnection { if let Some(response_buffer_vec) = self.response_buffer.as_mut() { let bytes_to_be_written = response_buffer_vec.len(); let write_result = match self.tx_file.take() { - Some(file) => self + Some(raw_fd) => self .stream - .send_with_fd(response_buffer_vec.as_slice(), file.as_raw_fd()) + .send_with_fd(response_buffer_vec.as_slice(), raw_fd) .map_err(|e| std::io::Error::from_raw_os_error(e.errno())), None => self.stream.write(response_buffer_vec.as_slice()), }; diff --git a/src/response.rs b/src/response.rs index a3d39fe..2f5a6b7 100644 --- a/src/response.rs +++ b/src/response.rs @@ -1,8 +1,8 @@ // Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -use std::fs::File; use std::io::{Error as WriteError, Write}; +use std::os::unix::io::RawFd; use crate::ascii::{COLON, CR, LF, SP}; use crate::common::{Body, Version}; @@ -194,8 +194,8 @@ pub struct Response { status_line: StatusLine, headers: ResponseHeaders, body: Option, - /// The optional file associated with the response. - pub file: Option, + /// The optional file descriptor associated with the response. + pub file: Option, } impl PartialEq for Response {