Skip to content

mod_http3/include/quic/h3q_stream.h

Structs

Name
struct h3q_vec
struct h3q_write_result

Types

Name
typedef struct h3q_vec h3q_vec
typedef struct h3q_write_result h3q_write_result

Functions

Name
int64_t h3q_stream_id(h3q_stream * st)
h3q_write_result h3q_stream_write(h3q_stream * st, const h3q_vec * vec, size_t nvec, int fin)
int h3q_stream_is_write_blocked(h3q_stream * st)
int h3q_stream_read(h3q_stream * st, unsigned char * buf, size_t read_size, size_t * nread, int * fin)
void h3q_stream_is_read_finished(h3q_stream * st, int * read_finished, int * write_finished)
void h3q_stream_reset(h3q_stream * st, uint64_t err)
void h3q_stream_free(h3q_stream * st)

Types Documentation

typedef h3q_vec

typedef struct h3q_vec h3q_vec;

One buffer to send; layout-compatible with nghttp3_vec.

typedef h3q_write_result

typedef struct h3q_write_result h3q_write_result;

What a stream write achieved, and how it stopped.

Functions Documentation

function h3q_stream_id

int64_t h3q_stream_id(
    h3q_stream * st
)

Parameters:

  • st Stream to query.

Return: The stream's id, or -1 when st is NULL.

Stream id.

function h3q_stream_write

h3q_write_result h3q_stream_write(
    h3q_stream * st,
    const h3q_vec * vec,
    size_t nvec,
    int fin
)

Parameters:

  • st Stream to write to.
  • vec Buffers to send.
  • nvec Number of buffers in vec.
  • fin Non-zero to close the stream after these bytes.

Return: What was accepted, and whether the write blocked or broke.

Note: Bytes count as acknowledged once accepted: OpenSSL reports no per-stream acknowledgements.

Write buffers to a stream, optionally closing it.

function h3q_stream_is_write_blocked

int h3q_stream_is_write_blocked(
    h3q_stream * st
)

Parameters:

  • st Stream to query.

Return: Non-zero when blocked.

Whether the stream can currently accept more bytes.

function h3q_stream_read

int h3q_stream_read(
    h3q_stream * st,
    unsigned char * buf,
    size_t read_size,
    size_t * nread,
    int * fin
)

Parameters:

  • st Stream to read from.
  • buf Destination buffer.
  • read_size Capacity of buf.
  • nread Out: bytes written to buf.
  • fin Out: non-zero once the peer has finished sending.

Return: 1 if bytes were read, 0 otherwise.

Read from a stream.

function h3q_stream_is_read_finished

void h3q_stream_is_read_finished(
    h3q_stream * st,
    int * read_finished,
    int * write_finished
)

Parameters:

  • st Stream to query.
  • read_finished Out: non-zero if reading is finished or reset.
  • write_finished Out: non-zero if writing is finished or reset.

Report whether each direction of a stream has finished.

function h3q_stream_reset

void h3q_stream_reset(
    h3q_stream * st,
    uint64_t err
)

Parameters:

  • st Stream to reset; NULL is ignored.
  • err Application error code to report.

Abort the sending half of a stream.

function h3q_stream_free

void h3q_stream_free(
    h3q_stream * st
)

Parameters:

  • st Stream to free; NULL is ignored.

Free a stream handle.

Source code

/*
 * Copyright (c) 2026 The mod_http3 Project Authors. All rights reserved.
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef H3Q_STREAM_H
#define H3Q_STREAM_H

#include <stddef.h>
#include <stdint.h>

#include "quic/h3q.h"

typedef struct h3q_vec
{
    const uint8_t* base;
    size_t len;
} h3q_vec;

typedef struct h3q_write_result
{
    size_t accepted;
    unsigned blocked : 1;
    unsigned broken : 1;
} h3q_write_result;

int64_t h3q_stream_id(h3q_stream* st);

h3q_write_result h3q_stream_write(h3q_stream* st, const h3q_vec* vec, size_t nvec, int fin);

int h3q_stream_is_write_blocked(h3q_stream* st);

int h3q_stream_read(h3q_stream* st, unsigned char* buf, size_t read_size, size_t* nread, int* fin);

void h3q_stream_is_read_finished(h3q_stream* st, int* read_finished, int* write_finished);

void h3q_stream_reset(h3q_stream* st, uint64_t err);

void h3q_stream_free(h3q_stream* st);

#endif /* H3Q_STREAM_H */