Alien-nghttp3
view release on metacpan or search on metacpan
vendor/nghttp3-1.18.0/lib/nghttp3_stream.h view on Meta::CPAN
#define NGHTTP3_STREAM_TYPE_CONTROL 0x00U
#define NGHTTP3_STREAM_TYPE_PUSH 0x01U
#define NGHTTP3_STREAM_TYPE_QPACK_ENCODER 0x02U
#define NGHTTP3_STREAM_TYPE_QPACK_DECODER 0x03U
#define NGHTTP3_STREAM_TYPE_UNKNOWN UINT64_MAX
typedef enum nghttp3_ctrl_stream_state {
NGHTTP3_CTRL_STREAM_STATE_FRAME_TYPE,
NGHTTP3_CTRL_STREAM_STATE_FRAME_LENGTH,
NGHTTP3_CTRL_STREAM_STATE_SETTINGS,
NGHTTP3_CTRL_STREAM_STATE_GOAWAY,
NGHTTP3_CTRL_STREAM_STATE_MAX_PUSH_ID,
NGHTTP3_CTRL_STREAM_STATE_IGN_FRAME,
NGHTTP3_CTRL_STREAM_STATE_SETTINGS_ID,
NGHTTP3_CTRL_STREAM_STATE_SETTINGS_VALUE,
NGHTTP3_CTRL_STREAM_STATE_PRIORITY_UPDATE_PRI_ELEM_ID,
NGHTTP3_CTRL_STREAM_STATE_PRIORITY_UPDATE,
NGHTTP3_CTRL_STREAM_STATE_ORIGIN_ORIGIN_LEN,
NGHTTP3_CTRL_STREAM_STATE_ORIGIN_ASCII_ORIGIN,
} nghttp3_ctrl_stream_state;
typedef enum nghttp3_req_stream_state {
NGHTTP3_REQ_STREAM_STATE_FRAME_TYPE,
NGHTTP3_REQ_STREAM_STATE_FRAME_LENGTH,
NGHTTP3_REQ_STREAM_STATE_DATA,
NGHTTP3_REQ_STREAM_STATE_HEADERS,
NGHTTP3_REQ_STREAM_STATE_IGN_FRAME,
NGHTTP3_REQ_STREAM_STATE_IGN_REST,
} nghttp3_req_stream_state;
typedef struct nghttp3_varint_read_state {
uint64_t acc;
size_t left;
} nghttp3_varint_read_state;
typedef struct nghttp3_stream_read_state {
nghttp3_varint_read_state rvint;
nghttp3_settings_entry iv;
nghttp3_frame fr;
uint64_t left;
int state;
} nghttp3_stream_read_state;
/* NGHTTP3_STREAM_FLAG_NONE indicates that no flag is set. */
#define NGHTTP3_STREAM_FLAG_NONE 0x0000U
/* NGHTTP3_STREAM_FLAG_TYPE_IDENTIFIED is set when a unidirectional
stream type is identified. */
#define NGHTTP3_STREAM_FLAG_TYPE_IDENTIFIED 0x0001U
/* NGHTTP3_STREAM_FLAG_FC_BLOCKED indicates that stream is blocked by
QUIC flow control. */
#define NGHTTP3_STREAM_FLAG_FC_BLOCKED 0x0002U
/* NGHTTP3_STREAM_FLAG_READ_DATA_BLOCKED indicates that application is
temporarily unable to provide data. */
#define NGHTTP3_STREAM_FLAG_READ_DATA_BLOCKED 0x0004U
/* NGHTTP3_STREAM_FLAG_WRITE_END_STREAM indicates that application
finished to feed outgoing data. */
#define NGHTTP3_STREAM_FLAG_WRITE_END_STREAM 0x0008U
/* NGHTTP3_STREAM_FLAG_QPACK_DECODE_BLOCKED indicates that stream is
blocked due to QPACK decoding. */
#define NGHTTP3_STREAM_FLAG_QPACK_DECODE_BLOCKED 0x0010U
/* NGHTTP3_STREAM_FLAG_READ_EOF indicates that remote endpoint sent
fin. */
#define NGHTTP3_STREAM_FLAG_READ_EOF 0x0020U
/* NGHTTP3_STREAM_FLAG_SHUT_WR indicates that any further write
operation to a stream is prohibited. */
#define NGHTTP3_STREAM_FLAG_SHUT_WR 0x0100U
/* NGHTTP3_STREAM_FLAG_SHUT_RD indicates that a read-side stream is
closed abruptly and any incoming and pending stream data is just
discarded for a stream. */
#define NGHTTP3_STREAM_FLAG_SHUT_RD 0x0200U
/* NGHTTP3_STREAM_FLAG_SERVER_PRIORITY_SET indicates that server
overrides stream priority. */
#define NGHTTP3_STREAM_FLAG_SERVER_PRIORITY_SET 0x0400U
/* NGHTTP3_STREAM_FLAG_PRIORITY_UPDATE_RECVED indicates that server
received PRIORITY_UPDATE frame for this stream. */
#define NGHTTP3_STREAM_FLAG_PRIORITY_UPDATE_RECVED 0x0800U
typedef enum nghttp3_stream_http_state {
NGHTTP3_HTTP_STATE_NONE,
NGHTTP3_HTTP_STATE_REQ_INITIAL,
NGHTTP3_HTTP_STATE_REQ_HEADERS_BEGIN,
NGHTTP3_HTTP_STATE_REQ_HEADERS_END,
NGHTTP3_HTTP_STATE_REQ_DATA_BEGIN,
NGHTTP3_HTTP_STATE_REQ_DATA_END,
NGHTTP3_HTTP_STATE_REQ_TRAILERS_BEGIN,
NGHTTP3_HTTP_STATE_REQ_TRAILERS_END,
NGHTTP3_HTTP_STATE_REQ_END,
NGHTTP3_HTTP_STATE_RESP_INITIAL,
NGHTTP3_HTTP_STATE_RESP_HEADERS_BEGIN,
NGHTTP3_HTTP_STATE_RESP_HEADERS_END,
NGHTTP3_HTTP_STATE_RESP_DATA_BEGIN,
NGHTTP3_HTTP_STATE_RESP_DATA_END,
NGHTTP3_HTTP_STATE_RESP_TRAILERS_BEGIN,
NGHTTP3_HTTP_STATE_RESP_TRAILERS_END,
NGHTTP3_HTTP_STATE_RESP_END,
} nghttp3_stream_http_state;
typedef enum nghttp3_stream_http_event {
NGHTTP3_HTTP_EVENT_DATA_BEGIN,
NGHTTP3_HTTP_EVENT_DATA_END,
NGHTTP3_HTTP_EVENT_HEADERS_BEGIN,
NGHTTP3_HTTP_EVENT_HEADERS_END,
NGHTTP3_HTTP_EVENT_MSG_END,
} nghttp3_stream_http_event;
typedef struct nghttp3_stream nghttp3_stream;
/*
* nghttp3_stream_acked_data is a callback function which is invoked
* when data sent on stream denoted by |stream_id| supplied from
* application is acknowledged by remote endpoint. The number of
* bytes acknowledged is given in |datalen|.
*
* The implementation of this callback must return 0 if it succeeds.
* Returning NGHTTP3_ERR_CALLBACK_FAILURE will return to the caller
* immediately. Any values other than 0 is treated as
* NGHTTP3_ERR_CALLBACK_FAILURE.
*/
typedef int (*nghttp3_stream_acked_data)(nghttp3_stream *stream,
int64_t stream_id, uint64_t datalen,
void *user_data);
typedef struct nghttp3_stream_callbacks {
nghttp3_stream_acked_data acked_data;
} nghttp3_stream_callbacks;
typedef struct nghttp3_http_state {
/* content_length is the value of received content-length header
field. */
int64_t content_length;
/* recv_content_length is the number of body bytes received so
far. */
int64_t recv_content_length;
nghttp3_pri pri;
/* status_code is HTTP status code received. This field is used
if connection is initialized as client. */
int32_t status_code;
uint32_t flags;
} nghttp3_http_state;
struct nghttp3_stream {
union {
struct {
const nghttp3_mem *mem;
nghttp3_objalloc *out_chunk_objalloc;
nghttp3_objalloc *stream_objalloc;
nghttp3_tnode node;
nghttp3_pq_entry qpack_blocked_pe;
nghttp3_stream_callbacks callbacks;
nghttp3_ringbuf frq;
nghttp3_ringbuf chunks;
nghttp3_ringbuf outq;
/* inq stores the stream raw data which cannot be read because
stream is blocked by QPACK decoder. */
nghttp3_ringbuf inq;
nghttp3_qpack_stream_context qpack_sctx;
/* conn is a reference to underlying connection. It could be NULL
if stream is not a request stream. */
nghttp3_conn *conn;
void *user_data;
/* unsent_bytes is the number of bytes in outq not written yet */
uint64_t unsent_bytes;
/* outq_idx is an index into outq where next write is made. */
size_t outq_idx;
/* ack_base is the number of bytes acknowledged by a remote
endpoint where the first element in outq is positioned at. */
uint64_t ack_base;
/* ack_offset is the number of bytes acknowledged by a remote
endpoint so far. */
uint64_t ack_offset;
uint64_t unscheduled_nwrite;
nghttp3_stream_type type;
nghttp3_stream_read_state rstate;
struct {
uint64_t offset;
} tx;
struct {
nghttp3_stream_http_state hstate;
nghttp3_http_state http;
} rx;
uint16_t flags;
};
nghttp3_opl_entry oplent;
};
};
nghttp3_objalloc_decl(stream, nghttp3_stream, oplent)
int nghttp3_stream_new(nghttp3_stream **pstream, int64_t stream_id,
const nghttp3_stream_callbacks *callbacks,
nghttp3_objalloc *out_chunk_objalloc,
nghttp3_objalloc *stream_objalloc,
const nghttp3_mem *mem);
void nghttp3_stream_del(nghttp3_stream *stream);
void nghttp3_varint_read_state_reset(nghttp3_varint_read_state *rvint);
void nghttp3_stream_read_state_reset(nghttp3_stream_read_state *rstate);
nghttp3_ssize nghttp3_read_varint(nghttp3_varint_read_state *rvint,
const uint8_t *begin, const uint8_t *end,
int fin);
/*
* nghttp3_stream_frq_emplace adds new space for nghttp3_frame to
* stream->frq, and assigns the pointer to the space to |*pfr| if it
* succeeds.
*
* This function returns 0 if it succeeds, or one of the following
* negative error codes:
*
* NGHTTP3_ERR_NOMEM
* Out of memory.
*/
int nghttp3_stream_frq_emplace(nghttp3_stream *stream, nghttp3_frame **pfr);
int nghttp3_stream_fill_outq(nghttp3_stream *stream);
int nghttp3_stream_write_stream_type(nghttp3_stream *stream);
size_t nghttp3_stream_writev(nghttp3_stream *stream, int *pfin,
nghttp3_vec *vec, size_t veccnt);
int nghttp3_stream_write_qpack_decoder_stream(nghttp3_stream *stream);
( run in 1.837 second using v1.01-cache-2.11-cpan-99fa8243a42 )