Orbit Framework 2.0.0
A high-performance asynchronous C++20 HTTP server framework.
Loading...
Searching...
No Matches
orbit::server::QuicHttp3Session Class Reference

Manages an HTTP/3 session over a QUIC connection. More...

#include <QuicHttp3Session.hpp>

Collaboration diagram for orbit::server::QuicHttp3Session:

Public Member Functions

 QuicHttp3Session (QuicConnection &quic_conn)
 Constructs a QuicHttp3Session.
 
 ~QuicHttp3Session ()
 
bool init ()
 Initializes the HTTP/3 session.
 
nghttp3_conn * get_conn () const
 Gets the underlying nghttp3 connection.
 
nghttp3_ssize process_stream_data (int64_t stream_id, const uint8_t *data, size_t datalen, bool fin)
 
void submit_response (int64_t stream_id, http::HttpResponse &response, bool has_body, bool streaming=false)
 
void submit_data (int64_t stream_id, std::string_view chunk)
 
void end_stream (int64_t stream_id)
 

Private Member Functions

std::shared_ptr< Http3Stream > get_or_create_stream (int64_t stream_id)
 
void handle_request (std::shared_ptr< Http3Stream > stream)
 
void submit_status (int64_t stream_id, http::HttpStatus status)
 

Static Private Member Functions

static int on_acked_stream_data (nghttp3_conn *conn, int64_t stream_id, uint64_t datalen, void *conn_user_data, void *stream_user_data)
 
static int on_stream_close (nghttp3_conn *conn, int64_t stream_id, uint64_t app_error_code, void *conn_user_data, void *stream_user_data)
 
static int on_recv_data (nghttp3_conn *conn, int64_t stream_id, const uint8_t *data, size_t datalen, void *conn_user_data, void *stream_user_data)
 
static int on_deferred_consume (nghttp3_conn *conn, int64_t stream_id, size_t consumed, void *conn_user_data, void *stream_user_data)
 
static int on_begin_headers (nghttp3_conn *conn, int64_t stream_id, void *conn_user_data, void *stream_user_data)
 
static int on_recv_header (nghttp3_conn *conn, int64_t stream_id, int32_t token, nghttp3_rcbuf *name, nghttp3_rcbuf *value, uint8_t flags, void *conn_user_data, void *stream_user_data)
 
static int on_end_headers (nghttp3_conn *conn, int64_t stream_id, int fin, void *conn_user_data, void *stream_user_data)
 
static int on_end_stream (nghttp3_conn *conn, int64_t stream_id, void *conn_user_data, void *stream_user_data)
 
static nghttp3_ssize read_data (nghttp3_conn *conn, int64_t stream_id, nghttp3_vec *vec, size_t veccnt, uint32_t *pflags, void *conn_user_data, void *stream_user_data)
 

Private Attributes

QuicConnection & quic_conn_
 
nghttp3_conn * httpconn_ {nullptr}
 
std::unordered_map< int64_t, std::shared_ptr< Http3Stream > > streams_
 

Detailed Description

Manages an HTTP/3 session over a QUIC connection.

Callbacks run on the event loop with the connection's mutex held; the submit_* functions are called by Http3ResponseWriter from worker threads, which take the same mutex first.

Constructor & Destructor Documentation

◆ QuicHttp3Session()

orbit::server::QuicHttp3Session::QuicHttp3Session ( QuicConnection &  quic_conn)
explicit

Constructs a QuicHttp3Session.

Parameters
quic_connThe underlying QUIC connection.

◆ ~QuicHttp3Session()

orbit::server::QuicHttp3Session::~QuicHttp3Session ( )

Member Function Documentation

◆ end_stream()

void orbit::server::QuicHttp3Session::end_stream ( int64_t  stream_id)

◆ get_conn()

nghttp3_conn * orbit::server::QuicHttp3Session::get_conn ( ) const
inline

Gets the underlying nghttp3 connection.

Returns
Pointer to nghttp3_conn.

◆ get_or_create_stream()

std::shared_ptr< Http3Stream > orbit::server::QuicHttp3Session::get_or_create_stream ( int64_t  stream_id)
private

◆ handle_request()

void orbit::server::QuicHttp3Session::handle_request ( std::shared_ptr< Http3Stream >  stream)
private

◆ init()

bool orbit::server::QuicHttp3Session::init ( )

Initializes the HTTP/3 session.

Returns
true on success, false otherwise.

◆ on_acked_stream_data()

static int orbit::server::QuicHttp3Session::on_acked_stream_data ( nghttp3_conn *  conn,
int64_t  stream_id,
uint64_t  datalen,
void *  conn_user_data,
void *  stream_user_data 
)
staticprivate

◆ on_begin_headers()

static int orbit::server::QuicHttp3Session::on_begin_headers ( nghttp3_conn *  conn,
int64_t  stream_id,
void *  conn_user_data,
void *  stream_user_data 
)
staticprivate

◆ on_deferred_consume()

static int orbit::server::QuicHttp3Session::on_deferred_consume ( nghttp3_conn *  conn,
int64_t  stream_id,
size_t  consumed,
void *  conn_user_data,
void *  stream_user_data 
)
staticprivate

◆ on_end_headers()

static int orbit::server::QuicHttp3Session::on_end_headers ( nghttp3_conn *  conn,
int64_t  stream_id,
int  fin,
void *  conn_user_data,
void *  stream_user_data 
)
staticprivate

◆ on_end_stream()

static int orbit::server::QuicHttp3Session::on_end_stream ( nghttp3_conn *  conn,
int64_t  stream_id,
void *  conn_user_data,
void *  stream_user_data 
)
staticprivate

◆ on_recv_data()

static int orbit::server::QuicHttp3Session::on_recv_data ( nghttp3_conn *  conn,
int64_t  stream_id,
const uint8_t *  data,
size_t  datalen,
void *  conn_user_data,
void *  stream_user_data 
)
staticprivate

◆ on_recv_header()

static int orbit::server::QuicHttp3Session::on_recv_header ( nghttp3_conn *  conn,
int64_t  stream_id,
int32_t  token,
nghttp3_rcbuf *  name,
nghttp3_rcbuf *  value,
uint8_t  flags,
void *  conn_user_data,
void *  stream_user_data 
)
staticprivate

◆ on_stream_close()

static int orbit::server::QuicHttp3Session::on_stream_close ( nghttp3_conn *  conn,
int64_t  stream_id,
uint64_t  app_error_code,
void *  conn_user_data,
void *  stream_user_data 
)
staticprivate

◆ process_stream_data()

nghttp3_ssize orbit::server::QuicHttp3Session::process_stream_data ( int64_t  stream_id,
const uint8_t *  data,
size_t  datalen,
bool  fin 
)

Feeds received stream data to nghttp3. Returns the bytes nghttp3 consumed (owed back as flow-control credit), or a negative nghttp3 error.

◆ read_data()

static nghttp3_ssize orbit::server::QuicHttp3Session::read_data ( nghttp3_conn *  conn,
int64_t  stream_id,
nghttp3_vec *  vec,
size_t  veccnt,
uint32_t *  pflags,
void *  conn_user_data,
void *  stream_user_data 
)
staticprivate

◆ submit_data()

void orbit::server::QuicHttp3Session::submit_data ( int64_t  stream_id,
std::string_view  chunk 
)

◆ submit_response()

void orbit::server::QuicHttp3Session::submit_response ( int64_t  stream_id,
http::HttpResponse &  response,
bool  has_body,
bool  streaming = false 
)

Submits a response. Takes ownership of response.file_fd when a file body is sent. With streaming, the body follows via submit_data() and end_stream(). Caller holds the connection mutex.

◆ submit_status()

void orbit::server::QuicHttp3Session::submit_status ( int64_t  stream_id,
http::HttpStatus  status 
)
private

Member Data Documentation

◆ httpconn_

nghttp3_conn* orbit::server::QuicHttp3Session::httpconn_ {nullptr}
private

◆ quic_conn_

QuicConnection& orbit::server::QuicHttp3Session::quic_conn_
private

◆ streams_

std::unordered_map<int64_t, std::shared_ptr<Http3Stream> > orbit::server::QuicHttp3Session::streams_
private

The documentation for this class was generated from the following file: