pub async fn send_outgoing_response(&self, message: &mut OutgoingResponse) -> io::Result<()> {
        if message.parts.buffer.is_empty() {
            let mut buffer = BytesMut::new();

            let ctx = PrintCtx {
                method: None,
                uri: None,
            };

            message
                .msg
                .headers
                .insert(Name::CONTENT_LENGTH, message.msg.body.len().to_string());

            write!(
                buffer,
                "{}\r\n{}\r\n",
                message.msg.line.print_ctx(ctx),
                message.msg.headers
            )
            .map_err(|e| {
                // wrap
                io::Error::new(io::ErrorKind::Other, e)
            })?;

            buffer.extend_from_slice(&message.msg.body);

            message.parts.buffer = buffer.freeze();
        }

        let target = message.parts.destination[0];

        log::trace!(
            "Sending response to {}\n{:?}",
            target,
            BytesPrint(&message.parts.buffer)
        );

        message
            .parts
            .transport
            .send(&message.parts.buffer, message.parts.destination[0])
            .await
    }
/// Print the request to its buffer (if needed) and send it via the transport
Print the request to its buffer (if needed) and send it via the transport
Print the request to its buffer ( if needed ) and send it via the transport
pub async fn send_outgoing_response(&self, message: &mut OutgoingResponse) -> io::Result<()> {
        if message.parts.buffer.is_empty() {
            let mut buffer = BytesMut::new();
            let ctx = PrintCtx {
                method: None,
                uri: None,
            };
            message
                .msg
                .headers
                .insert(Name::CONTENT_LENGTH, message.msg.body.len().to_string());
            write!(
                buffer,
                "{}\r\n{}\r\n",
                message.msg.line.print_ctx(ctx),
                message.msg.headers
            )
            .map_err(|e| {
                // wrap
                io::Error::new(io::ErrorKind::Other, e)
            })?;
            buffer.extend_from_slice(&message.msg.body);
            message.parts.buffer = buffer.freeze();
        }
        let target = message.parts.destination[0];
        log::trace!(
            "Sending response to {}\n{:?}",
            target,
            BytesPrint(&message.parts.buffer)
        );
        message
            .parts
            .transport
            .send(&message.parts.buffer, message.parts.destination[0])
            .await
    }
pub async fn send_outgoing_response ( & self , message : & mut OutgoingResponse ) -> io :: Result < ( ) > { if message . parts . buffer . is_empty ( ) { let mut buffer = BytesMut :: new ( ) ; let ctx = PrintCtx { method : None , uri : None , } ; message . msg . headers . insert ( Name :: CONTENT_LENGTH , message . msg . body . len ( ) . to_string ( ) ) ; write ! ( buffer " \r \n \r \n " message msg line print_ctx ( ctx ) message msg headers ) . map_err ( | e | { // wrap io :: Error :: new ( io :: ErrorKind :: Other , e ) } ) ? ; buffer . extend_from_slice ( & message . msg . body ) ; message . parts . buffer = buffer . freeze ( ) ; } let target = message . parts . destination [ 0 ] ; log :: trace ! ( " \n " target BytesPrint ( message parts buffer ) ) ; message . parts . transport . send ( & message . parts . buffer , message . parts . destination [ 0 ] ) . await }
Print the request to its buffer (if needed) and send it via the transport
Print the request to its buffer ( if needed ) and send it via the transport
&self
message
&mut OutgoingResponse