__`WebTransport`__ ([draftversion2](https://datatracker.ietf.org/doc/html/draft-vvv-webtransport-http3-02)) is supportedandcanbeenabledusing[`Http3Parameters`](struct.Http3Parameters.html).
// process_output can return 3 values, data to be sent, time duration when process_output should // be called, and None when Http3Client is done. matchclient.process_output(Instant::now()){ Output::Datagram(dgram)=>{ // Send dgram on a socket. socket.send_to(&dgram[..],dgram.destination())
} Output::Callback(duration)=>{ // the client is idle for “duration”, set read timeout on the socket to this value and // poll the socket for reading in the meantime. socket.set_read_timeout(Some(duration)).unwrap(); } Output::None=>{ // client is done. } };
...
// Reading new data coming for the network. matchsocket.recv_from(&mutbuf[..]){ Ok((sz,remote))=>{ letd=Datagram::new(remote,*local_addr,&buf[..sz]); client.process_input(d,Instant::now()); } Err(err)=>{ eprintln!("UDPerror:{}",err); } } ```
mod buffered_send_stream; mod client_events; mod conn_params; mod connection; mod connection_client; mod connection_server; mod control_stream_local; mod control_stream_remote; pubmod features; mod frames; mod headers_checks; mod priority; mod push_controller; mod qlog; mod qpack_decoder_receiver; mod qpack_encoder_receiver; mod recv_message; mod request_target; mod send_message; mod server; mod server_connection_events; mod server_events; mod settings; mod stream_type_reader;
use std::{cell::RefCell, fmt::Debug, rc::Rc};
use buffered_send_stream::BufferedStream; pubuse client_events::{Http3ClientEvent, WebTransportEvent}; pubuse conn_params::Http3Parameters; pubuse connection::{Http3State, WebTransportSessionAcceptAction}; pubuse connection_client::Http3Client; use features::extended_connect::WebTransportSession; use frames::HFrame; pubuse neqo_common::Header; use neqo_common::MessageType; use neqo_qpack::Error as QpackError; pubuse neqo_transport::{streams::SendOrder, Output, StreamId}; use neqo_transport::{
AppError, Connection, Error as TransportError, RecvStreamStats, SendStreamStats,
}; pubuse priority::Priority; pubuse server::Http3Server; pubuse server_events::{
Http3OrWebTransportStream, Http3ServerEvent, WebTransportRequest, WebTransportServerEvent,
}; use stream_type_reader::NewStreamType;
usecrate::priority::PriorityHandler;
type Res<T> = Result<T, Error>;
#[derive(Clone, Debug, PartialEq, Eq)] pubenum Error {
HttpNoError,
HttpGeneralProtocol,
HttpGeneralProtocolStream, /* this is the same as the above but it should only close a
* stream not a connection. */ // When using this error, you need to provide a value that is unique, which // will allow the specific error to be identified. This will be validated in CI.
HttpInternal(u16),
HttpStreamCreation,
HttpClosedCriticalStream,
HttpFrameUnexpected,
HttpFrame,
HttpExcessiveLoad,
HttpId,
HttpSettings,
HttpMissingSettings,
HttpRequestRejected,
HttpRequestCancelled,
HttpRequestIncomplete,
HttpConnect,
HttpVersionFallback,
HttpMessageError,
QpackError(neqo_qpack::Error),
trait RecvStream: Stream { /// The stream reads data from the corresponding quic stream and returns `ReceiveOutput`. /// The function also returns true as the second parameter if the stream is done and /// could be forgotten, i.e. removed from all records. /// /// # Errors /// /// An error may happen while reading a stream, e.g. early close, protocol error, etc. fn receive(&mutself, conn: &mut Connection) -> Res<(ReceiveOutput, bool)>;
/// # Errors /// /// An error may happen while reading a stream, e.g. early close, etc. fn reset(&mutself, close_type: CloseType) -> Res<()>;
/// The function allows an app to read directly from the quic stream. The function /// returns the number of bytes written into `buf` and true/false if the stream is /// completely done and can be forgotten, i.e. removed from all records. /// /// # Errors /// /// An error may happen while reading a stream, e.g. early close, protocol error, etc. fn read_data(&mutself, _conn: &mut Connection, _buf: &mut [u8]) -> Res<(usize, bool)> {
Err(Error::InvalidStreamId)
}
/// This function is only implemented by `WebTransportRecvStream`. fn stats(&mutself, _conn: &mut Connection) -> Res<RecvStreamStats> {
Err(Error::Unavailable)
}
}
trait HttpRecvStream: RecvStream { /// This function is similar to the receive function and has the same output, i.e. /// a `ReceiveOutput` enum and bool. The bool is true if the stream is completely done /// and can be forgotten, i.e. removed from all records. /// /// # Errors /// /// An error may happen while reading a stream, e.g. early close, protocol error, etc. fn header_unblocked(&mutself, conn: &mut Connection) -> Res<(ReceiveOutput, bool)>;
trait SendStream: Stream { /// # Errors /// /// Error may occur during sending data, e.g. protocol error, etc. fn send(&mutself, conn: &mut Connection) -> Res<()>; fn has_data_to_send(&self) -> bool; fn stream_writable(&self); fn done(&self) -> bool;
/// # Errors /// /// Error may occur during sending data, e.g. protocol error, etc. fn send_data(&mutself, _conn: &mut Connection, _buf: &[u8]) -> Res<usize>;
/// # Errors /// /// It may happen that the transport stream is already closed. This is unlikely. fn close(&mutself, conn: &mut Connection) -> Res<()>;
/// # Errors /// /// It may happen that the transport stream is already closed. This is unlikely. fn close_with_message(
&mutself,
_conn: &mut Connection,
_error: u32,
_message: &str,
) -> Res<()> {
Err(Error::InvalidStreamId)
}
/// This function is called when sending side is closed abruptly by the peer or /// the application. fn handle_stop_sending(&mutself, close_type: CloseType); fn http_stream(&mutself) -> Option<&mutdyn HttpSendStream> {
None
}
/// # Errors /// /// It may happen that the transport stream is already closed. This is unlikely. fn send_data_atomic(&mutself, _conn: &mut Connection, _buf: &[u8]) -> Res<()> {
Err(Error::InvalidStreamId)
}
/// This function is only implemented by `WebTransportSendStream`. fn stats(&mutself, _conn: &mut Connection) -> Res<SendStreamStats> {
Err(Error::Unavailable)
}
}
trait HttpSendStream: SendStream { /// This function is used to supply headers to a http message. The /// function is used for request headers, response headers, 1xx response and /// trailers. /// /// # Errors /// /// This can also return an error if the underlying stream is closed. fn send_headers(&mutself, headers: &[Header], conn: &mut Connection) -> Res<()>; fn set_new_listener(&mutself, _conn_events: Box<dyn SendStreamEvents>) {}
}
/// This enum is used to mark a different type of closing a stream: /// `ResetApp` - the application has closed the stream. /// `ResetRemote` - the stream was closed by the peer. /// `LocalError` - There was a stream error on the stream. The stream errors are errors /// that do not close the complete connection, e.g. unallowed headers. /// `Done` - the stream was closed without an error. #[derive(Debug, Clone, Copy, PartialEq, Eq)] enum CloseType {
ResetApp(AppError),
ResetRemote(AppError),
LocalError(AppError),
Done,
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.