Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions include/tquic.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ typedef struct quic_conn_stats_t {

typedef struct http3_methods_t {
/**
* Called when the stream got headers.
* Called when the stream receives a header or trailer field section.
*/
void (*on_stream_headers)(void *ctx,
uint64_t stream_id,
Expand Down Expand Up @@ -1445,7 +1445,7 @@ int http3_stream_set_priority(struct http3_conn_t *conn,
const struct http3_priority_t *priority);

/**
* Send HTTP/3 request or response headers on the given stream.
* Send initial HTTP/3 request or response headers on the given stream.
*/
int http3_send_headers(struct http3_conn_t *conn,
struct quic_conn_t *quic_conn,
Expand All @@ -1454,6 +1454,21 @@ int http3_send_headers(struct http3_conn_t *conn,
size_t headers_len,
bool fin);

/**
* Send an additional HTTP/3 field section on the given stream.
*
* Clients can only send trailer sections. Servers can also send additional
* response field sections before the response body. Once a trailer section is
* sent, no more HEADERS or DATA frames can be sent on the stream.
*/
int http3_send_additional_headers(struct http3_conn_t *conn,
struct quic_conn_t *quic_conn,
uint64_t stream_id,
const struct http3_header_t *headers,
size_t headers_len,
bool is_trailer_section,
bool fin);

/**
* Send HTTP/3 request or response body on the given stream.
*/
Expand Down
28 changes: 26 additions & 2 deletions src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2349,7 +2349,7 @@ pub struct Header {
value_len: usize,
}

/// Send HTTP/3 request or response headers on the given stream.
/// Send initial HTTP/3 request or response headers on the given stream.
#[cfg(feature = "h3")]
#[no_mangle]
pub extern "C" fn http3_send_headers(
Expand All @@ -2368,6 +2368,30 @@ pub extern "C" fn http3_send_headers(
}
}

/// Send an additional HTTP/3 field section on the given stream.
///
/// Clients can only send trailer sections. Servers can also send additional
/// response field sections before the response body. Once a trailer section is
/// sent, no more HEADERS or DATA frames can be sent on the stream.
#[cfg(feature = "h3")]
#[no_mangle]
pub extern "C" fn http3_send_additional_headers(
conn: &mut Http3Connection,
quic_conn: &mut Connection,
stream_id: u64,
headers: *const Header,
headers_len: size_t,
is_trailer_section: bool,
fin: bool,
) -> c_int {
let h3_headers = headers_from_ptr(headers, headers_len);

match conn.send_additional_headers(quic_conn, stream_id, &h3_headers, is_trailer_section, fin) {
Ok(_) => 0,
Err(e) => e.to_errno() as c_int,
}
}

/// Send HTTP/3 request or response body on the given stream.
#[cfg(feature = "h3")]
#[no_mangle]
Expand Down Expand Up @@ -2516,7 +2540,7 @@ pub extern "C" fn quic_set_logger(
#[cfg(feature = "h3")]
#[repr(C)]
pub struct Http3Methods {
/// Called when the stream got headers.
/// Called when the stream receives a header or trailer field section.
pub on_stream_headers:
Option<fn(ctx: *mut c_void, stream_id: u64, headers: &Http3Headers, fin: bool)>,

Expand Down
Loading